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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-05-19 : 03:22:55
|
| how can I check if a number is evenin other languages I would do if mynumber Mod 2 Then evennumberdoes mod work in sql as well? what's teh syntax? |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-05-19 : 03:24:18
|
[code]if (@number % 2) = 0 print 'EVEN'else print 'ODD'[/code] KH |
 |
|
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-05-19 : 03:33:01
|
| thanks..tell me for if statement do I have to do with a begin or end or can I do it in one like like this:if @filtered=1 then @valid=0 |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-05-19 : 03:52:18
|
quote: Originally posted by esthera thanks..tell me for if statement do I have to do with a begin or end or can I do it in one like like this:if @filtered=1 then @valid=0
Yes you can, but it makes no sense. You only need a BEGIN...END if you want to execute several statements for the investigated situation, like:If This Is True BEGIN Do This Do This Too Do This Last ENDELSE Do Only ThisIn your case, the code should look like:if @filtered=1 then SELECT @valid=0or if @filtered=1 then SET @valid=0 |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-19 : 04:02:30
|
| The word THEN is not needed in SQL (It is front end sysntax)if @filtered=1 SELECT @valid=0or if @filtered=1 SET @valid=0MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|