-- Attempt to insert an explicit ID value of 3;
-- should return a warning.
INSERT INTO products (id, product) VALUES(3, 'garden shovel')
GO
你可从通过设置idetity_insert on来允许显式地插入。当identity_insert设为on 时,表的每一个插入语句都要包括一列名列表。

-- SET IDENTITY_INSERT to ON.
SET IDENTITY_INSERT products ON
GO

-- Attempt to insert an explicit ID value of 3
INSERT INTO products (id, product) VALUES(3, 'garden shovel').
GO

SELECT *
FROM products
GO
-- Drop products table.
DROP TABLE products
GO

posted on 2011-11-11 16:28  账号难注册  阅读(268)  评论(0)    收藏  举报