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 |
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-09-03 : 11:52:26
|
why this simple blk is giving me wrong answer , as it is very clear that char(9) is tabdeclare @currentchar varchar(10) =char(9) IF (@currentChar <> CHAR(32) OR @currentChar <> CHAR(9)) print 'it is neither space nor tab' else print 'it is either tab or space' output'it is neither space nor tab'-Neil |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-09-03 : 13:04:09
|
it changed it as below, but my question is why the above one did not worked?declare @currentchar varchar(10) =' 'declare @tab char(1) = char(9)declare @space char(1) = char(32) IF @currentChar in (@space,@tab) print 'in space.tab' else print 'no space no tab' in space.tab-Neil |
 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2012-09-03 : 13:22:48
|
| IF (@currentChar <> CHAR(32) OR @currentChar <> CHAR(9)) The first part is true, it is true that char(9) <> char(32).You can set @currentChar to anything and your if statement will still always be true.Jim Everyday I learn something that somebody else already knew |
 |
|
|
aakcse
Aged Yak Warrior
570 Posts |
Posted - 2012-09-03 : 13:59:56
|
| Thanks got it ..simple mistake.. thats the reason ... when I changed the code to IF @currentChar in (@space,@tab) print 'in space.tab' else print 'no space no tab'it worked fine for me...-Neil |
 |
|
|
|
|
|