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 |
|
cipriani1984
Constraint Violating Yak Guru
304 Posts |
Posted - 2011-01-12 : 06:47:29
|
| Hi,I just wanted to ask why the following IF's wont work in SQL, but would work in Java, ASP etc.I have the following IF statement in my SP.select @datatype = [Data_Type] from dbo.tableWHERE ID = 2IF @datatype = 'APP_CAT'BEGINENDELSE IF @datatype = 'CAT_CAT'BEGIN ENDELSE IF @datatype = 'CAT_TOPIC'BEGINENDAny help / explaniation would be much appreciated! :) |
|
|
Sachin.Nand
2937 Posts |
Posted - 2011-01-12 : 06:59:22
|
What do you mean by wont work in SQL ?declare @datatype varchar(10)select @datatype = 'APP_CAT'IF @datatype = 'APP_CAT'BEGINprint '1'ENDELSE IF @datatype = 'CAT_CAT'BEGIN print '2'ENDELSE IF @datatype = 'CAT_TOPIC'BEGINprint '3'END PBUH |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-01-12 : 08:49:00
|
| i doubt the variable @datatype that OPs is using doesnt have enough length to hold full value causing it to be truncated or it is of type char.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2011-01-12 : 10:16:25
|
| Post the full code used in the procedureMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|