I need to have a list that I can identify in my entire database
SET IDENTITY_INSERT ON
Thank you and thank you for helping me.
I think you need this:
SELECT 'SET IDENTITY_INSERT ' +OBJECT_NAME(OBJECT_ID)+ ' ON'
FROM SYS.IDENTITY_COLUMNS
WHERE OBJECT_NAME(OBJECT_ID) not like 'sqlagent_%'
AND OBJECT_NAME(OBJECT_ID) not like 'queue_messages%'
EDIT:
SELECT 'SET IDENTITY_INSERT ' +OBJECT_NAME(OBJECT_ID)+ ' ON;'+'SET IDENTITY_INSERT ' +OBJECT_NAME(OBJECT_ID)+ ' OFF;'
FROM SYS.IDENTITY_COLUMNS
WHERE OBJECT_NAME(OBJECT_ID) not like 'sqlagent_%'
AND OBJECT_NAME(OBJECT_ID) not like 'queue_messages%'
IDENTITY_INSERTis set per session, and will beOFFfor a new session, so you don't really have to check it - you probably know if you set it toONon the same session, or you can create a new session.