sqlserver查看外键

 

 1.sqlserver2008通过外键查看表名

select Object_name(parent_obj) 表名,* from sysobjects where xtype like 'f' and name='FK_INT_CASE_RELA_CASEID'

 

 

2.sqlserver2008通过表名查看外键----方法一

select name from sysobjects where xtype like 'f' and Object_name(parent_obj)='BPM_DATA_0'

 

3.sqlserver2008通过表名查看外键----方法二

select name from sys.foreign_key_columns f 
join sys.objects o 
on f.constraint_object_id=o.object_id 
where f.parent_object_id=object_id('BPM_DATA_0')

 

 

4.sqlserver里面的xtype含义:

f:代表外键

pk:代表主键

u:代表用户表

s:代表系统表

 

refurl:http://zhidao.baidu.com/link?url=gyhEF2AHcOx6dZ17XwwKXBH6vRtHaIkRqLFOWeZ59KLFXs8bUTliBwrhYzyM8Y-jJdQrwvAgHu8t-z96wMEQfq

refurl:http://www.cnblogs.com/emanlee/archive/2010/02/26/1674519.html

refurl:http://www.myexception.cn/sql-server/336893.html

你可能感兴趣的:(sqlserver)