I want to do this in code, not with ALT+F1.
Call this stored procedure using the datareader role, then check datareader. hasrows() . If the condition value is true ( 1 ), then the table has identity column if set. If not then it doesn't have an identity column.
We can use the SQL IDENTITY function to insert identity values in the table created by SQL SELECT INTO statement. By default, if a source table contains an IDENTITY column, then the table created using a SELECT INTO statement inherits it.
You cannot alter a column to be an IDENTITY column. What you'll need to do is create a new column which is defined as an IDENTITY from the get-go, then drop the old column, and rename the new one to the old name.
You can also do it this way:
select columnproperty(object_id('mytable'),'mycolumn','IsIdentity')
Returns 1 if it's an identity, 0 if not.
sp_help tablename
In the output look for something like this:
Identity Seed Increment Not For Replication ----------- ------- ------------ ---------------------- userid 15500 1 0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With