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
 SQL Server Development (2000)
 using case in the place of multiple if conditions

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-05-21 : 07:40:25
Bhupendra Singh writes "Hi,

I want to execute different sql queries based on the values
passed by the parameter. It will give me the flexibility to
have a single stored procedure returning different resutls
depending on the value of parameter.

Vb and other programming languages allow us to use
Case Statements (if depending on the value of one variable
different statements will execute) instead of using multiple
if conditions.

Can Sql Server has any statement to reduce multiple if conditions. Remember, I would like to write multiple lines of
code between each case.

Thanks in advance.

Warm Regards,

Bhupendra Singh"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-05-21 : 08:00:35
Yes, T-SQL has several Control-of-Flow constructs. If you want to return different row-sets based on you input param, use a if...else construct. If the row-set to be returned is the same, then you maybe be able to use CASE to evaluate your conditions in the WHERE clause or integrated into the SELECT list.

Jay White
{0}
Go to Top of Page
   

- Advertisement -