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 - 2006-02-27 : 12:09:39
|
| Arnold writes "HiI have a Stored Procedure like thisCREATE PROCEDURE ShowUsers @Department int,@OnlyActive bitASIF(@OnlyActive=1)BEGIN SELECT * FORM USERS WHERE IDDepartment=@Department AND Active=1ENDELSEBEGIN SELECT * FROM USERS WHERE IDDepartment=@DepartmentENDIs it possible to do this in one line - something like:SELECT * FORM USERS WHERE IDDepartment=@Department IF(@OnlyActive=1) AND Active=1I tried to put the Statement into an variable and then EXECUTE(@varible) but i get "@department must be declared"Is it possible or do i have to create two SQL-Statements?Hope you can help meThanksArnold" |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|