一、查询数据库(sys.databases —— select *from sys.databases where name='<数据库名>')
select *from sys.databases where name='MyDatabase'
二、查询表(sysobjects —— select *from sysobjects where id=OBJECT_ID('<表名>'))
select *from sysobjects where id=OBJECT_ID('StudentsInfo')
三、查询列(syscolumns —— select COUNT(*) from syscolumns where name='<列名>' and id=OBJECT_ID('<表名>'))
select COUNT(*) from syscolumns where name='sname' and id=OBJECT_ID('studentsinfo')
四、查询存储过程或视图(select * from sysobjects where name='<视图或存储过程名>' AND type = 'P/V')