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 2005 Forums
 Transact-SQL (2005)
 whats wrong with this case function ???

Author  Topic 

missMac
Posting Yak Master

124 Posts

Posted - 2009-06-11 : 09:03:50
Hello Guys,

am trying to return a certain value for @x below, based on its status, but the variable remains as its original state and doesnt change

pls help

mm


declare @x varchar(500), @sally varchar(300)
set @x = '00'
SELECT @x as sally,
(
CASE
WHEN @x = '00' then '300'
WHEN LEFT(@x,1) = 'x' then 'Transaction could not be authorized. Please contact your bank or send an email '
WHEN LEFT(@x,1) = 'w' then 'GATEWAY Application error'
WHEN @x = '14' then 'GATEWAY Application error'
ELSE 'ERROR: Contact support'
END

) as sally
print @x



but @x always returns as the initial value


khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-11 : 09:10:25
[code]
declare @x varchar(500), @sally varchar(300)
set @x = '00'
SELECT @x as sally, =
(
CASE
WHEN @x = '00' then '300'
WHEN LEFT(@x,1) = 'x' then 'Transaction could not be authorized. Please contact your bank or send an email '
WHEN LEFT(@x,1) = 'w' then 'GATEWAY Application error'
WHEN @x = '14' then 'GATEWAY Application error'
ELSE 'ERROR: Contact support'
END

) as sally
print @x
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

raky
Aged Yak Warrior

767 Posts

Posted - 2009-06-11 : 09:12:19
Is this is what you want??
declare @x varchar(500)
set @x = '00'
SELECT @x =
CASE
WHEN @x = '00' then '300'
WHEN LEFT(@x,1) = 'x' then 'Transaction could not be authorized. Please contact your bank or send an email '
WHEN LEFT(@x,1) = 'w' then 'GATEWAY Application error'
WHEN @x = '14' then 'GATEWAY Application error'
ELSE 'ERROR: Contact support'
END

select @x as sally
print @x
Go to Top of Page

missMac
Posting Yak Master

124 Posts

Posted - 2009-06-11 : 09:20:30
Okidoks

thanks guys
Go to Top of Page
   

- Advertisement -