I\'ve searched for this, but threads in which it appeared tended to have answers from people who didn\'t understand the question.
Take the following syntax:
<
If you want to know about the session variable... Good question, but I cant see where this information would be usefull. In normal execution to check a normal table response to an insert, this should work!
-- If you only want to know if there is identity insert on a given table:
select is_identity
from sys.columns
where object_id = OBJECT_ID('MyTable', 'U') and name = 'column_Name'
-- Or... Use this if you want to execute something depending on the result:
if exists (select *
from sys.columns
where object_id = OBJECT_ID('MyTable', 'U') and is_identity = 1)
... your code considering identity insert
else
... code that should not run with identity insert
Have fun!