September 18, 2010 at 1:01 am
Hi,
For Eg,
This is table structure,
Create Table voucher
(
VoucherID int,
LocationID int,
SNo int,
aaa varchar(100),
bbb varchar(100),
CONSTRAINT PK_Voucher PRIMARY KEY(voucherID,LocationID,SNO)
)
Create Table RefTable
(
VID int,
LID int,
SNo int,
aaa varchar(100),
bbb varchar(100),
CONSTRAINT FK_RefTableVoucher FOREIGN KEY(VID,LID,SNo ) REFERENCES Voucher(voucherID,LocationID,SNO)
)
My requirement is, if i give Table name -Voucher.
Need to get all reference tablename ,reference column.
How can i achieve this.
September 18, 2010 at 1:53 am
The schema views that should contain this will be sys.columns, sys.foreign_keys and sys.foreign_key_columns. Joins are pretty simple and obvious
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 18, 2010 at 4:08 am
Thank You
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply