This is not very, but if you cannot find another way:
BEGIN TRY CREATE TABLE #temp (my_id INT IDENTITY NOT NULL) SET IDENTITY_INSERT #temp ON SET IDENTITY_INSERT #temp OFF DROP TABLE #temp END TRY BEGIN CATCH SELECT ERROR_MESSAGE() DROP TABLE #temp END CATCH
Then you can parse the result from ERROR_MESSAGE () to find out the name of the table (if any) for which it is set. If I find a better way, I will replace this answer.
Tom h source share