1. 程式人生 > >sql server關於表和表結構的一些查詢語句

sql server關於表和表結構的一些查詢語句

1.查詢出資料庫中,當前登入使用者下的表名

select name from sys.objects where type='U',或者

select name from sysobjects where xtype='u' and status>=0 

2.查詢一個表的欄位名

select name from syscolumns where id=object_id(''表名)

3.查詢一個表的欄位名和欄位型別

select column_name,data_type from information_schema.columns where table_name='Department'

3.查詢一個表的詳細資訊,包括建立時間,表結構,欄位型別,欄位長度

sp_help 表名 或者 sp_help '表名'

4.查詢出資料庫中的儲存過程

select name as procedureName from sysobjects where xtype='P'