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
 General SQL Server Forums
 New to SQL Server Programming
 foreign key referencing a exp column

Author  Topic 

ducletan
Starting Member

25 Posts

Posted - 2010-12-28 : 04:46:29
In sql 2005
table1 (brcd nvarchar(4))
table2 (brcd nvarchar(5))

I cant not:

1)
ALTER TABLE table1
ADD FOREIGN KEY (brcd) REFERENCES table2( substring(brcd,1,4))

or
2)
create view v1 as select substring(brcd,1,4) brcd from table2
ALTER TABLE table1
ADD FOREIGN KEY (brcd) REFERENCES v1( brcd)


give me the way to solve...

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-12-28 : 04:59:09
Please show us the table structures including primary keys and so on...

Ah, and the error message would be fine


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -