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 2000 Forums
 SQL Server Development (2000)
 Subquery in CHECK constraint

Author  Topic 

julianfraser
Starting Member

19 Posts

Posted - 2004-07-11 : 10:45:45
I need a work-around for this as SQL Server tells me that you cannot include subqueries in CHECK contraints and I'm not sure of the best way.

ALTER TABLE at_credit_transaction
ADD CONSTRAINT CN_credit_transaction_format
CHECK (transaction_typeID IN
(SELECT transaction_typeID FROM at_transaction_type WHERE transaction_format = 'CRE')
)
GO


Thanks,
Julian.

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2004-07-11 : 12:48:00
you can use a UDF that accepts a transaction_typeID and does the lookup in the table.

- Jeff
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-07-11 : 13:56:55
You could also use a trigger. (I can't believe I just said that.)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-07-11 : 15:01:08
Hiyo Silver (I can't believe I just said that.)
Go to Top of Page

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2004-07-11 : 17:18:21
awaaaaaaaay!!!!

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page
   

- Advertisement -