Adding Records to a Table with a Primary Key in MSSQL (T-SQL)
How to add data to a table with a Primary Key (when you need to ignore this primary key)
SET IDENTITY_INSERT tableA ON
-- Теперь можно делать список полей с Primary Key и добавлять записи так:
INSERT Into tableA ([id], [c2], [c3], [c4], [c5] )
SELECT [id], [c2], [c3], [c4], [c5] FROM tableB
-- Вот так нельзя "INSERT Into tableA SELECT ........"
SET IDENTITY_INSERT tableA OFF
Comments (0)
No comments yet.