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 |
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2007-12-03 : 06:05:07
|
How to Check values of input parameter of sp with select CaseSuppose @Other is the input parameter of the Stored Procis this the correct syntax?Select @Other Case 'DPC'select @BillOther = DPC from tbmidc_transaction where typeoftransaction='Bill'select @ReceiptOther =DPC from tbmidc_transaction where typeoftransaction='Receipt'select @ArrersOther =DPC from tbmidc_transaction where typeoftransaction='Arrers'...........And So on |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-03 : 06:19:16
|
[code]Select Case When @Other = 'Col1' then Col1 When @Other = 'Col2' then Col2 End as SomeColFrom Table[/code]But please note that in above case all the columns i.e. col1, col2 etc. should be of same datatype.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
|
|
Swati Jain
Posting Yak Master
139 Posts |
Posted - 2007-12-03 : 06:29:06
|
quote: Originally posted by harsh_athalye
Select Case When @Other = 'Col1' then Col1 When @Other = 'Col2' then Col2 End as SomeColFrom Table But please note that in above case all the columns i.e. col1, col2 etc. should be of same datatype.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED"
Hi Harsh,Thank u for replies.But Can I use 2 parameters in the same querylikeSelect Case When @Other = 'Col1' then Select @BillingOther=@Other from table When @Other = 'Col2' then End as SomeCol,@BillingOther=@Other from table From Tableor such kind of query Possible |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-03 : 07:57:40
|
by table you meant the same table or different one?MadhivananFailing to plan is Planning to fail |
|
|
|
|
|