Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Snippet enables identity insert if the table [TABLE_NAME] has identity column.
- IF EXISTS(
- SELECT
- t.object_id
- FROM
- sys.tables t
- INNER JOIN sys.columns c
- ON t.object_id = c.object_id
- and c.is_identity = 1
- and t.name='TABLE_NAME')
- BEGIN
- SET IDENTITY_INSERT [dbo].[TABLE_NAME] ON
- END
- -- Don't forget to rollback.
- SET IDENTITY_INSERT [dbo].[TABLE_NAME] OFF
Advertisement
Add Comment
Please, Sign In to add comment