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)
 How to add a constraint on a non-unique field ?

Author  Topic 

WaterWolf
Starting Member

24 Posts

Posted - 2008-12-10 : 10:11:25
Hello, I have a two tables, the structure of which would be:

VATTable:
----------------------------
VATName | VATRate | Date |
----------------------------
'Standard'| 22 | 2/2/82|
----------------------------

CostTable:
------------------
VATName | Cost |
------------------
'Standard'| 22 |
------------------

CostTable references VATName in VATTable. VATName is not unique in VATTable - when I'm selecting from it, the correct record is selected based on the current date.

I want to constrain VATName in CostTable so that only a VATName that already exists in VATTable can be inserted. However as this is non unique I can't use a foreign key. Is there any way of doing this ?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-10 : 10:19:22
i think you might have to use an "instead of" trigger to implement this logic
Go to Top of Page
   

- Advertisement -