I think you will have better luck with this version:
declare @newtend int
declare @ccnum varchar(50)
declare @tendertypeID int
set @ccnum = 3000000000000000
set @tendertypeID = 4
select
@newtend = CASE
WHEN left(@ccnum,1) = 3
THEN 11
ELSE @tendertypeID
END
==+==+==+==+==+==+==+==+==+==+==
Brendt W. Hess
Database Administrator, Motosport, Inc
brendt.[Email address protected]
==+==+==+==+==+==+==+==+==+==+==
-----Original Message-----
From: Clint Nash
[mailto:mssqldba-ezmlmshield-x9946530.[Email address protected]
Sent: Thursday, September 27, 2007 4:53 PM
To: LazyDBA Discussion
Subject: Simple Case statement
Good Evening,
I have a very simple case statement that is driving me nuts, this should
be very simple, but every turn I take it errors out.
declare @newtend int
declare @ccnum varchar(50)
declare @tendertypeID int
set @ccnum = 3000000000000000
set @tendertypeID = 4
select @newtend = (select ID = CASE tendertypeID WHEN left(@ccnum,1) = 3
THEN 11 Else @tendertypeID end)
Basically all I am trying to determine is if the first digit of the
@ccnum parameter is a 3 then the value of the variable @newtendID needs
to set = 11 otherwise it should be set to the value of @tendertypeID.
Thanks,
Clint.
---------------------------------------------------------------------
TO REPLY TO EVERYBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY To post a
dba job: http://jobs.lazydba.com To subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
MS Sql Server LazyDBA home page