SQL Server批量插入和指定自动编号值插入
SET IDENTITY_INSERT [TB_Person] ON
INSERT
INTO [TB_Person]([PersonId], [PersonName], [Age])
SELECT 24, '210600', '66' UNION
SELECT 25, '210820', '67'
SET IDENTITY_INSERT [TB_Person] OFF
INSERT
INTO [TB_Person]([PersonId], [PersonName], [Age])
SELECT 24, '210600', '66' UNION
SELECT 25, '210820', '67'
SET IDENTITY_INSERT [TB_Person] OFF
发现:看到CodeSmith里ScriptTableData生成的脚本,呵呵,INSERT 原来可以这样,基础知识没学好啊。
说明:PersonId 是标示(IDENTITY)字段
用途:项目数据的初始化,尤其是现有项目增加功能的时候。