************ Drop identity *******************
update syscolumns
set colstat =0
where id = object_id('tbl1') and name = 'rowid1'
Explanation:
tbl1 is a table name
rowid1 is a column name
if colstat = 0 means drop identity in a column
************ ADD identity IN EXISTING column *******************
Step 1:
update syscolumns
set colstat = 1
where id = object_id('tbl1') and name = 'rowid1'
Step 2: If data already exists in table and column is primary key use is
DBCC CHECKIDENT ('tbl1', RESEED,XX)
Explanation:
xx is a last column value + 1 as int.
tbl1 is a table name
rowid1 is a column name
if colstat = 1 means add identity in a column
No comments:
Post a Comment