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
 Development Tools
 ASP.NET
 Checking values of input parameter of sp

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 Case
Suppose @Other is the input parameter of the Stored Proc
is 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 SomeCol
From Table[/code]

But please note that in above case all the columns i.e. col1, col2 etc. should be of same datatype.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

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 SomeCol
From Table


But please note that in above case all the columns i.e. col1, col2 etc. should be of same datatype.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"



Hi Harsh,
Thank u for replies.But Can I use 2 parameters in the same query
like
Select
Case When @Other = 'Col1' then Select @BillingOther=@Other from table
When @Other = 'Col2' then
End as SomeCol,@BillingOther=@Other from table
From Table
or such kind of query Possible
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-03 : 07:57:40
by table you meant the same table or different one?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -