Skip to content

Instantly share code, notes, and snippets.

@Vaccano
Created September 9, 2015 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vaccano/3eb4cd6fef90446aaf3a to your computer and use it in GitHub Desktop.
Save Vaccano/3eb4cd6fef90446aaf3a to your computer and use it in GitHub Desktop.
Update Property on an Identity Column
USE pubs
GO
EXEC sp_configure 'allow update', '1'
RECONFIGURE WITH OVERRIDE
GO
DECLARE @col varchar(128), @table varchar(128)
-- for find identity column (if colstat =1 then identity is on)
SELECT @col=name
FROM syscolumns
WHERE id=OBJECT_ID('pubs..test') AND (colstat & 1 <> 0)
-- SELECT @col
IF (@col IS NOT null) BEGIN
UPDATE syscolumns
SET colstat = colstat ^ 1
WHERE id = OBJECT_ID('pubs..test') and name = @col
END
EXEC sp_configure 'allow update', '0'
RECONFIGURE WITH OVERRIDE
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment