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 - 2002-02-26 : 09:16:21
|
| TDawg writes "I would like to build a select query dynamically in a stored proc. We I try this it doesn't work. Is there anyway to do this with stored procedure.Ex.Select * FROM tblUsersWHEREIf Len(FName) > 0 Then Firstname = FName ANDEnd ifIf Len(Lname) > 0 Then Lastname = LnameEnd IfI would like to do this in a stored proc, but I am having a lot of problems. Any ideas?" |
|
|
andre
Constraint Violating Yak Guru
259 Posts |
Posted - 2002-02-26 : 09:33:01
|
You could do this without dynamic SQL:Select * FROM tblUsers WHERE FirstName=IsNull(@FName,Firstname) ANDLastname=IsNull(@Lname,Lastname) |
 |
|
|
|
|
|