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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 CASE Statement - Stored Procedure.

Author  Topic 

vbjohn
Starting Member

32 Posts

Posted - 2005-10-11 : 11:40:18
Can someone tell me what I am doing wrong.

I am trying to test this out by using the Print Statement.

It is telling me:
Error 156: Incorrect syntax near the keyword 'CASE'/
Incorrect syntax near the keyword 'END'.

CASE @TType
WHEN 'U' THEN
Print 'U'
WHEN 'I' THEN
Print 'I'
WHEN 'D' THEN
Print 'D'
END

SreenivasBora
Posting Yak Master

164 Posts

Posted - 2005-10-11 : 11:55:18
declare @TType varchar(1), @TType1 varchar(1)
set @TType = 'I'

select @TType1 = CASE @TType WHEN 'U' THEN 'U' WHEN 'I' THEN 'I' WHEN 'D' THEN 'D' END


Print @TType1

With Regards
BSR
Go to Top of Page

vbjohn
Starting Member

32 Posts

Posted - 2005-10-11 : 11:59:59
Awesome thanks.
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2005-10-11 : 16:52:06
[code]
declare @TType varchar(1)
set @TType = 'I'
select CASE @TType WHEN 'U' THEN 'U' WHEN 'I' THEN 'I' WHEN 'D' THEN 'D' END as colTType

declare @TType varchar(1)
set @TType = 'J'
select CASE
WHEN @TType = 'U' THEN 'U'
WHEN @TType = 'I' THEN 'I'
WHEN @TType = 'D' THEN 'D'
ELSE 'whatdoyado'
END as colTType
[/code]

two other styles

I wish someone would start an Official XML Rant Thread.
Go to Top of Page
   

- Advertisement -