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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-03-11 : 07:16:53
|
| Ashok writes "I would like to use Condition in the select statement in Stored procedurefor examplecreate Procedure test@EmployeeID int=0Select * from Employee If @EmployeeID = 0 then No Actionelse where EmployeeID=@EmployeeIDGobut I don't want to store it in string in @SQL and execute it..is there any solution for this.Thanks" |
|
|
Andraax
Aged Yak Warrior
790 Posts |
Posted - 2003-03-11 : 07:19:34
|
| Hi Ashok!Try this:select * from Employeewhere case when @EmployeeID=0 then 0 else EmployeeID end = case when @EmployeeID=0 then 0 else @EmployeeID end |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2003-03-11 : 08:41:45
|
| orSelect * from Employee where EmployeeID=@EmployeeID or @EmployeeID = 0==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|