How to tell if a key in the sql server is identity? How do I find out? The version is 2014.
How to tell if a key in the sql server is identity? How do I find out? The version is 2014.
SELECT is_identity
FROM sys.columns
WHERE object_id = object_id('Nome_da_sua_tabela')
AND name = 'Nome_da_sua_coluna'
It will return 1 if the column is identity
Complementing the response of @Artur, if you want a relation (table / column) of all the identity keys of a given database:
select o.name, c.name
from sys.objects o inner join sys.columns c on o.object_id = c.object_id
where c.is_identity = 1
You can use COLUMNPROPERTY for this.
select columnproperty(object_id('NomeTabela'),'NomeColuna','IsIdentity')
This will return one of the options:
1 = TRUE
0 = FALSE
NULL = The entry is not valid.