@manhnguyenv

Welcome to my blog!

Id Auto Increase

April 3, 2019 23:59

Id Auto Increase (edit)

https://stackoverflow.com/questions/13772019/sql-check-if-a-column-auto-increments

ALTER TABLE YourTable DROP COLUMN IDCol
ALTER TABLE YourTable ADD IDCol INT IDENTITY(1,1)
SELECT 
'Diary' as Table_Name
, 'Id' as Column_Name,
case is_identity
when 1 then 'True'
when 0 then 'False'
end as Is_Identity
FROM sys.columns
WHERE
object_id = object_id('Diary')
AND name = 'Id'

Categories