SQL server queries all the table names and fields in the database.
SELECT * FROM INFORMATION_SCHEMA.columns WHERE TABLE_NAME = 'account'
SELECT
(Case when a. colorder = 1 then d. name else ''end) as table name. -- if the table name is the same, null is returned.
A. colorder as field serial number,
A. name as field name,
(Case when COLUMNPROPERTY (a. id, a. name, 'isidentity ') = 1 then' √ 'else' end) as identity,
(Case when (SELECT count (*) FROM sysobjects -- query the primary key
WHERE (name in
(SELECT name FROM sysindexes
WHERE (id = a. id) AND (indid in
(SELECT indid FROM sysindexkeys
WHERE (id = a. id) AND (colid in
(SELECT colid FROM syscolumns
WHERE (id = a. id) AND (name = a. name ))
)))))
AND (xtype = 'pk')> 0 then' √ 'else' end) as primary key, -- Query primary key END
B. name as type,
A. length as occupies the number of bytes,
COLUMNPROPERTY (a. id, a. name, 'precision ') as length,
Isnull (COLUMNPROPERTY (a. id, a. name, 'Scale'), 0) as decimal places,
(Case when a. isnullable = 1 then '√ 'else'' end) as allow null,
Isnull (e. text, '') as default value,
Isnull (g. [value], '') AS field description
FROM syscolumns a left join policypes B
On a. xtype = B. xusertype
Inner join sysobjects d
On a. id = d. id and d. xtype = 'U' and d. name <> 'dtproperties'
Left join syscomments e
On a. cdefault = e. id
Left join sys. extended_properties g
On a. id = g. major_id AND a. colid = g. minor_id
Order by a. id, a. colorder
How does SQL server query all tables? Not all tables are named.
Select name from sysobjects where xtype = 'U ';
How can I query all the table names and field types in a specified database in SQL Server?
There is a set of system views below sys. You can find all the data you need through those views ~~