User Tools

Site Tools


sysobjects_sql

Sysobject SQL

Code snippets that get useful information out of the sysobjects table.

Sysobjects.type Meaning (SQL Server) Meaning (Sybase)
C CHECK constraint Computed column
D Default or DEFAULT constraint Default
F FOREIGN KEY constraint SQLJ function
FN Scalar function
IF Inlined table-function
L Log Log
N Partition condition
P Stored procedure Transact-SQL or SQLJ procedure
PK PRIMARY KEY constraint (type is K)
PR Prepare objects (created by Dynamic SQL)
R Rule
RF Replication filter stored procedure
RI Referential constraint
S System table System table
TF Table function
TR Trigger Trigger
U User table User table
V View View
X Extended stored procedure
XP Extended stored procedure

All User Tables

SELECT sysobjects.name AS TableName
       , *
FROM   sysobjects
WHERE  sysobjects.type = 'U'

All Columns from User Tables

SELECT sysobjects.name AS TableName
       , syscolumns.name AS ColumnName
       , *
FROM   sysobjects
JOIN   syscolumns ON syscolumns.id = sysobjects.id
WHERE  sysobjects.type = 'U'

All Identity Columns from User Tables

SELECT sysobjects.name AS TableName
       , syscolumns.name AS ColumnName
       , *
FROM   sysobjects
JOIN   syscolumns ON syscolumns.id = sysobjects.id
WHERE  sysobjects.type = 'U'
AND    syscolumns.status >= 128
sysobjects_sql.txt · Last modified: 2017/01/01 20:05 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki