¿Cómo puedo determinar si una columna es una columna de identidad en MSSQL 2000?
Quiero hacer esto en código, no con ALT+F1.
25
Author: Alexander Prokofyev, 2008-10-10
4 answers
También puedes hacerlo de esta manera:
select columnproperty(object_id('mytable'),'mycolumn','IsIdentity')
Devuelve 1 si es una identidad, 0 si no.
60
Author: Blorgbeard,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 20:16:59
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 20:16:59
sp_help tablename
En la salida busque algo como esto:
Identity Seed Increment Not For Replication
----------- ------- ------------ ----------------------
userid 15500 1 0
16
Author: Patrick McElhaney,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 20:05:05
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 20:05:05
Ajuste la cláusula WHERE
a la medida:
select
a.name as TableName,
b.name as IdentityColumn
from
sysobjects a inner join syscolumns b on a.id = b.id
where
columnproperty(a.id, b.name, 'isIdentity') = 1
and objectproperty(a.id, 'isTable') = 1
4
Author: Luke Bennett,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 20:15:46
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 20:15:46
Como expansión en la respuesta de @Blogbeard
Si te gusta la consulta pura y no las funciones incorporadas
select col_name(sys.all_objects.object_id, column_id) as id from sys.identity_columns
join sys.all_objects on sys.identity_columns.object_id = sys.all_objects.object_id
where sys.all_objects.name = 'system_files'
0
Author: Tschallacka,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-26 13:51:27
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-26 13:51:27