Listare tabele ce au coloane cu IDENTITY

Configurare noua (How To)

Situatie

Mai jos este o procedura ce listeaza toate tabelele de pe o baza de date Microsoft SQL Server ce contin coloane – definit IDENTITY.

Solutie

create procedure FindTableWithIdentityColumns

 

as

 

SELECT [Table] = s.[Name] + N’.’ + t.[Name]

FROM [sys].tables t

JOIN [sys].schemas  s ON t.[schema_id] = s.[schema_id]

WHERE EXISTS

(

SELECT * FROM [sys].identity_columns i

WHERE i.[object_id] = t.[object_id]

);

Tip solutie

Permanent
Etichetare:

Voteaza

(4 din 9 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?