取得庫中所有的外來鍵

2021-05-22 11:09:44 字數 899 閱讀 3361

select a.外來鍵,b.tbl_nme as 主表,b.col_nme as 主列,c.tbl_nme as 參照表,c.col_nme as 參照列

from

(select a.name as 外來鍵,a.parent_object_id,b.parent_column_id,a.referenced_object_id,b.referenced_column_id

from sys.foreign_keys a

left join sys.foreign_key_columns b

on a.object_id=b.constraint_object_id ) as a

left join

(select b.name as tbl_nme,a.name as col_nme,b.id as obj_id,a.colid  from syscolumns a

left join sysobjects b

on a.id=b.id

where b.xtype='u'

) bon a.parent_object_id=b.obj_id and a.parent_column_id=b.colid

left join

(select b.name as tbl_nme,a.name as col_nme,b.id as obj_id,a.colid  from syscolumns a

left join sysobjects b

on a.id=b.id

where b.xtype='u'

) con a.referenced_object_id=c.obj_id and a.referenced_column_id=c.colid

where c.tbl_nme='main_per'

C 中所有的符號

算術運算子 加 x y z 減 x y z 乘 x y z 除 x y z 賦值運算子 賦值 x 10 賦值與和 x 10 等於x x 10 賦值與減 x 10 賦值與乘 x 10 賦值與除 x 10 賦值位與 x 0x02 賦值位或 x 0x02 邏輯操作符 邏輯與 if x 0xff 邏輯或 i...

查詢資料庫中所有的表

select from sysobjects where xtype u 查詢當前資料庫下所有使用者建立的表 xtype char 2 物件型別。可以是下列物件型別中的一種 c check 約束 d 預設值或 default 約束 f foreign key 約束 l 日誌 fn 標量函式 if 內...

取得窗體中所有控制代碼 zt

delphi 源 將下面這兩個變數宣告為全域性變數 myhwnd array 1.200 of hwnd myhwndcount integer 1 這個過程便能夠獲得主窗體下的全部子窗體控制代碼 procedure tmainform.gethwnd dad hwnd var bakh hwnd ...