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.
| Author |
Topic |
|
rajkumarrai_bis
Yak Posting Veteran
78 Posts |
Posted - 2005-06-06 : 10:36:25
|
| pls help me outi want to apply a check constraint on a field in a tablecondition is the that the field value should always be greater or equal to a value stored in other tablein short , how can i use other table's field value in check constraintthanks in advance |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-06 : 11:16:36
|
use instead of or after trigger, whichever suits you.Go with the flow & have fun! Else fight the flow |
 |
|
|
rajkumarrai_bis
Yak Posting Veteran
78 Posts |
Posted - 2005-06-07 : 01:41:56
|
| thanks spirit1 for ur responsei know what u r telling ,but the problem is that i dont know how to capture inserted values in a trigger , plz provide me the code in which u have captured inserted values in a triggeri think after_insert trigger will be useful for me |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2005-06-07 : 02:12:00
|
| the inserted values will be in "inserted"example query:select count(*) from insertedwhich will you the number of records inserted at that moment--------------------keeping it simple... |
 |
|
|
byrmol
Shed Building SQL Farmer
1591 Posts |
Posted - 2005-06-07 : 04:35:00
|
This can be done with a view...eg.CREATE VIEW YourTable_CONSTRAINTASSelect <column list>from YourTable YWHERE EXISTS (SELECT 1 from TargetTable TT WHERE Y.Value >= TT.Value AND <Key condition>)WITH CHECK Insert/update into this...DavidMA front-end is something that tries to violate a back-end. |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-06-07 : 04:58:07
|
good call david. forgot about WITH CHECK on views...Go with the flow & have fun! Else fight the flow |
 |
|
|
rajkumarrai_bis
Yak Posting Veteran
78 Posts |
Posted - 2005-06-07 : 06:55:49
|
| sorry to disturb the flowi know that all u people have given me usefull tips but now i have implemented check contraint in all the desired locations as work was of urgent naturecurrently i am using constant values , but needs to know how can i use other table's value in check constrainteg. exename > 105i want to use other table's field value in place of 105 |
 |
|
|
|
|
|