1. query all database names in the database:
SelectNameFromMaster.. sysdatabasesOrder ByName
2. query all the table names in a database:
SelectNameFromSysobjectsWhereXtype='U' Order ByName
3. query table structure information:
1 Select ( Case When A. colorder = 1 Then D. Name Else Null End ) Table Name, 2 A. colorder FIELD No., A. Name field name, 3 ( Case When Columnproperty (A. ID, A. Name, ' Isidentity ' ) = 1 Then ' √ ' Else '' End ) ID, 4 ( Case When ( Select Count (* ) From Sysobjects 5 Where (Name In ( Select Name From Sysindexes 6 Where (ID = A. ID) And (Indid In 7 (Select Indid From Sysindexkeys 8 Where (ID = A. ID) And (Colid In 9 ( Select Colid From Syscolumns Where (ID = A. ID) And (Name= A. Name ))))))) 10 And (Xtype = ' PK ' )) > 0 Then ' √ ' Else '' End ) Primary key, B. Name type, A. Length occupies the number of bytes, 11 Columnproperty (A. ID, A. Name, ' Precision ' ) As Length, 12 Isnull ( Columnproperty (A. ID, A. Name, ' Scale ' ), 0 ) As Decimal places ,( Case When A. isnullable = 1 Then ' √ ' Else '' End ) Can be empty, 13 Isnull (E. Text ,'' ) Default value, Isnull (G. [ Value ] , ' ' ) As [ Description ] 14 From Syscolumns 15 Left Join Policypes B On A. xtype = B. xusertype 16 Inner Join Sysobjects d On A. ID = D. id And D. xtype = ' U ' And D. Name <> ' Dtproperties ' 17 Left Join Syscomments E On A. cdefault = E. ID 18 Left Join SYS. extended_properties g On A. ID = G. major_id And A. colid= G. minor_id 19 Left Join SYS. extended_properties F On D. id = F. Class And F. minor_id = 0 20 Where B. Name Is Not Null 21 -- Where D. Name = 'table to be query' -- if only the specified table is queried, add this condition. 22 Order By A. ID, A. colorder