Wednesday, March 7, 2012

Identity Column Property

Hi,
It's my first time here , and my first steps with SqlServer too.
I would like to know if there is a way to check via transact-Sql if a column has Identity Property and if so wat are the the seed and increment values.
Thanks
SanduHere you go for the first one :

How to find whether a column is Identity column

select name from syscolumns where colstat & 1 = 1 and name = @.ColumnName

For the second one ...

IDENT_SEED
Returns the seed value (returned as numeric(@.@.MAXPRECISION,0)) specified during the creation of an identity column in a table or a view that has an identity column.

Syntax
IDENT_SEED ( 'table_or_view' )

IDENT_INCR
Returns the increment value (returned as numeric(@.@.MAXPRECISION,0)) specified during the creation of an identity column in a table or view that has an identity column.

Syntax
IDENT_INCR ( 'table_or_view' )|||Thanks a lot
sandu

No comments:

Post a Comment