nyk0r

Enable Identity Insert of possible

Apr 8th, 2011
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
T-SQL 0.29 KB | None | 0 0
  1. -- Snippet enables identity insert if the table [TABLE_NAME] has identity column.
  2.  
  3. IF EXISTS(
  4.     SELECT
  5.         t.object_id
  6.     FROM
  7.         sys.tables t
  8.     INNER JOIN sys.columns c
  9.         ON t.object_id = c.object_id
  10.         and c.is_identity = 1
  11.         and t.name='TABLE_NAME')
  12.     SET IDENTITY_INSERT [dbo].[TABLE_NAME] ON
Advertisement
Add Comment
Please, Sign In to add comment