IS there a system table I can join to so I can query to find all tables with a column flagged as ROWGUIDCOL?
thanks!
Advertisement
Answer
You could utilize sys.columns
with COLUMNPROPERTY
:
SELECT DISTINCT OBJECT_NAME(object_id) AS tab_name FROM sys.columns WHERE COLUMNPROPERTY(object_id, name, 'IsRowGuidCol') = 1
CREATE TABLE MyTable(ID UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWID()); CREATE TABLE MyTable2(ID UNIQUEIDENTIFIER ROWGUIDCOL PRIMARY KEY DEFAULT NEWSEQUENTIALID());
Output:
╔══════════╗ ║ tab_name ║ ╠══════════╣ ║ MyTable2 ║ ╚══════════╝