If you need to query the table structure, can the SQL statement be implemented? The following describes how to write SQL statements to query the table structure. It is helpful for you to learn SQL statements.
- -- Query non-system databases
- Select name FROM Master .. SysDatabases where dbid> 4
-
- -- Select all tables in the water database
- Use [water] SELECT name FROM sysobjects WHERE xtype = 'U' Or xtype = 'S'
-
- -- Select all user tables in the water database
- Use [water] SELECT name FROM sysobjects WHERE xtype = 'U' and objectproperty (id, 'ismsshipped ') = 0
-
- -- Query the field name, length, type, and field description of the admin table in the water database.
- Use [water] SELECT. [name] as 'field name',. length 'length', c. [name] 'type', e. value as 'field description' FROM syscolumns
- Left join policypes B on a. xusertype = B. xusertype
- Left join policypes c on a. xtype = c. xusertype
- Inner join sysobjects d on a. id = d. id and d. xtype = 'U'
- Left join sys. extended_properties e on a. id = e. major_id and a. colid = e. minor_id and e. name = 'Ms _ description'
- Where d. name = 'admin'
[Edit recommendations]
Use SQL statements to query consecutive segments
SQL statement writing for multi-condition query in a single table
Use SQL statements to query Time Periods
Use SQL statements to delete duplicate records
Example of batch SQL statement execution