SQLSERVER 查詢資料庫資訊

2022-09-20 00:21:09 字數 517 閱讀 5338

use dbname

-- 檢視表所有字段

select * from syscolumns where id=object_id('表名') order by id

select * from sysobjects where (xtype = 'u'

)goxtype可替換為如下引數

--c =check 約束

--d =預設值或 default 約束

--f =foreign key 約束

--l = 日誌 --fn =標量函式

--if =內嵌表函式

--p =儲存過程

--pk =primary key 約束(型別是 k)

--rf =複製篩選儲存過程

--s =系統表

--tf =表函式

--tr =觸發器

--u =使用者表

--uq =unique 約束(型別是 k)

--v =檢視

--x = 擴充套件儲存過程

查詢SQL Server2008資料庫表資訊

select 表名 case when a.colorder 1 then d.name else end,表說明 case when a.colorder 1 then isnull f.value,else end 字段序號 a.colorder 欄位名 a.name 標識 case when ...

SQL Server資料庫查詢

開啟我們的sql server資料庫,找到要查詢的資料庫表,右鍵單擊然後選擇新建查詢,select 選擇我們要查詢的表sys academe學院表 聯合 sys class.classname班級表的班級名稱和sys grade.gradename年級表的年級編號來查詢出資料。下面是查詢的 sele...

SQL Server 跨資料庫查詢

語句 select from 資料庫a.dbo.表a a,資料庫b.dbo.表b b where a.field b.field dbo 可以省略 如 select from 資料庫a.表a a,資料庫b.表b b where a.field b.field sqlserver資料庫 這句是對映乙個...