1. display all user databases:
Select dbid, name, filename from Master. DBO. sysdatabases where dbid> 4
2. display all tables in the database:
Current Database: Select name from {db_name} .. sysobjects where xtype = 'U'
Database creation: Select name from {db_name} .. sysobjects where xtype = 'U'
3. display all stored procedures in the database:
Select name, status from sysobjects where xtype = 'P'
4. view all fields in the table:
Show only field names: Select name from syscolumns where id = object_id ('table _ name ')
Show field details: Select syscolumns. name, policypes. name 'type', syscolumns. length from syscolumns, policypes where syscolumns. xusertype = policypes. xusertype and syscolumns. id = object_id ('table _ name ')
5. Select all different values of a field:
Select distinct field1 from Table1
6. Select a specified number of records:
Select top (10) field1 from Table1
7. Select all different values of a field:
Select distinct field1 from Table1