SELECT * FROM sysobjects WHERE xtype = <type>
<type>:
C: Check constraint
D: Default constraint
F: Foreign Key constraint
L: Log
P: Stored procedure
PK: Primary Key constraint
RF: Replication Filter stored procedure
S: System table
TR: Trigger
U: User table
UQ: Unique constraint
V: View
X: Extended stored procedure
1. Get all tables:
SELECT [name]
FROM sysobjects
WHERE xtype = 'U'
order by [name]
2. Get all columns by table:
SELECT syscolumns.name as [name],
systypes.name as [datatype],
syscolumns.length as [length]
FROM sysobjects
JOIN syscolumns ON sysobjects.id = syscolumns.id
JOIN systypes ON syscolumns.xtype=systypes.xtype
WHERE sysobjects.xtype='U' and sysobjects.name = <table name>
ORDER BY syscolumns.colid
Немає коментарів:
Дописати коментар