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 |
|
Guestuser18
Starting Member
34 Posts |
Posted - 2009-11-05 : 05:29:55
|
| HiI need to write an if statement to check if a field value is between 1-6, i.e. if the number was changed to 1 or 2 or 3 etcHow can I do this?I need something like(if value = 1-6) then....Any help would be greatThanks |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-05 : 05:36:28
|
Can you be more specific please?What do you want to do?Is it inside an SQL statement?Example? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Guestuser18
Starting Member
34 Posts |
Posted - 2009-11-05 : 05:45:39
|
| I'm writing a trigger.I need to check if the field that has just been updated has a number between 1-6, so something like. if (:NEW.value 1-6) then do somethingDoes make sense? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-05 : 05:48:05
|
Once again.Please show what you want to do inside the trigger.This question cannot be answered well without knowing the wanted statement. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Guestuser18
Starting Member
34 Posts |
Posted - 2009-11-05 : 05:56:01
|
| No I'm not detailing my whole trigger in this post just to try and get an answer to 1 if statement. Surely what I have provided is enough info. Forget the rest of the trigger I just need the correct syntax to write the statement. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-05 : 06:03:10
|
The condition can be placed- in an update statement, but I dont' know what you want to do- in a select statement, but I dont' know what you want to do- in a WHERE clause, but I dont' know what you want to doA trigger knows the "tables" inserted and deletedinserted and deleted can hold more than one record at runtime so the value-check should consider this, but I dont' know what you want to doI wish you good luck! No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Guestuser18
Starting Member
34 Posts |
Posted - 2009-11-05 : 06:07:18
|
| if (:NEW.VALUE) BETWEEN 1 AND 6 THENThats all I needed. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-11-05 : 06:11:08
|
But that's not a valid syntax in a trigger in T-SQL. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|