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 |
|
tvb2727
Starting Member
35 Posts |
Posted - 2010-10-16 : 17:56:54
|
| I want to create a trigger where when do an update statement it has to be less than the price already in the table. How would I pull the data already in the table to compare it against the attempted UPDATED data? |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-16 : 17:59:17
|
What should be the reaction if the new price isn't less than the price that is already in the table? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
tvb2727
Starting Member
35 Posts |
Posted - 2010-10-16 : 18:02:11
|
| It will just not allow the update statement to happen and gives an error. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-16 : 18:13:13
|
if exists(select * from yourTable t1 join inserted i on i.productId=t1.productId where t1.price <= i.price) BEGIN ROLLBACK TRANSACTION RAISERROR('Price(s) should always be less than existing prices', 16, 1) RETURNEND No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-10-16 : 18:14:46
|
With the given information I was not able to give more help.If that isn't what you want then please give table structure and sample data. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|