Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 want to know foreign key constraint name ..

Author  Topic 

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2009-07-01 : 07:07:36
Hi Friends,

I want to know the foreign key constraint name of particular table and a particular column.
example:

table name : mytable
column name : studentID

In the above table, I want to know the name of foreign key constraint on the column 'studentID'.

If there is no foreign key constraint on that column display 'null'

Regards
JS.Reddy

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-07-01 : 07:10:41
select object_name(constid)constraintname,object_name(id)tablename from sys.sysconstraints
where object_name(id) ='mytable'

or try
sp_help 'tbl_Common_HelpFiles_TextDetails'
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-01 : 07:12:24
See INFORMATION_SCHEMA.KEY_COLUMN_USAGE


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2009-07-01 : 07:17:48
Thank you so much.

quote:
Originally posted by Peso

See INFORMATION_SCHEMA.KEY_COLUMN_USAGE


N 56°04'39.26"
E 12°55'05.63"


Go to Top of Page

js.reddy
Yak Posting Veteran

80 Posts

Posted - 2009-07-01 : 07:18:35
Thank you so much.

quote:
Originally posted by bklr

select object_name(constid)constraintname,object_name(id)tablename from sys.sysconstraints
where object_name(id) ='mytable'

or try
sp_help 'tbl_Common_HelpFiles_TextDetails'

Go to Top of Page
   

- Advertisement -