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
 Transact-SQL (2000)
 SP and Control of Flw

Author  Topic 

TGarmon
Starting Member

18 Posts

Posted - 2002-03-19 : 10:15:25
Hello,

I am trying to develop an SP that based upon a parameter passed from a client will update particular columns of a table. Any ideas? I think I could do this with a case statement, but cannot seem to find an example.

--pseudo-code

Update SomeTable

IF @someparam =3
set this1a = some value1
set this1b = some value2
set this1c = some value3

If @someparam = 16
set this2a = some value4
set this2b = some value5
set this2c = some value6


Thanks for your help,
John

Jay99

468 Posts

Posted - 2002-03-19 : 10:24:17
http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=13981

Jay
<O>
Go to Top of Page

TGarmon
Starting Member

18 Posts

Posted - 2002-03-19 : 13:44:03
I guess I am still lost. Any more ideas?

Thanks,
John

Go to Top of Page

Jay99

468 Posts

Posted - 2002-03-19 : 13:54:36

create proc tgarmon
@somepararm int
as

update sometable
set this1a = case
when @someparam = 3 then somevalue1
else this1a end,
set this1b = case
when @someparam = 3 then somevalue2
else this1b end,
set this1c = case
when @someparam = 3 then somevalue3
else this1c end,
set this2a = case
when @someparam = 16 then somevalue4
else this2a end,
set this2b = case
when @someparam = 16 then somevalue5
else this2b end,
set this2c = case
when @someparam = 16 then somevalue6
else this2c end,

go


Jay
<O>


EDIT: AAHHHHH!!! I see the problem, your profile says you are a coldfusion programmer. (joke )

Edited by - Jay99 on 03/19/2002 13:56:14
Go to Top of Page

TGarmon
Starting Member

18 Posts

Posted - 2002-03-19 : 13:57:19
Thanks so much!!! That made sense.

John

Go to Top of Page

TGarmon
Starting Member

18 Posts

Posted - 2002-03-19 : 14:01:43
Your are correct about the CF bit. I know what I was trying to do, but could not figure out how to "say" it in T-SQL.

Thanks again,
John

Go to Top of Page
   

- Advertisement -