Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Handle No Params Passed
Message
 
 
To
05/11/2008 21:31:01
John Baird
Coatesville, Pennsylvania, United States
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 6.5 and older
Miscellaneous
Thread ID:
01359989
Message ID:
01360065
Views:
15
>>>If you read the question carefully, you'll see the following statement: It's possible for any combination of parameters to be passed. How do I change the WHERE clause to handle this?
>>>
>>>Notice the "its possible for ANY COMBINATION OF PARAMETERS". How do you account for getting 1 or 5 or 15?
>>
>>The original question only lists 3 parameters in an SP. How you're going to loop parameters in T-SQL?
>
>He didn't say ANY COMBINATION OF THE 3 PARAMETERS. Who said anything about t-sql? You create the dynamic sql statement in your code and execute it as a sql command. We do this alot. Also, there are ways of creating the dynamic sql in t-sql also, but I guess that is beyond basic t-sql.

I guess we read the question completely differently. He posted an SP and I assumed we want to be able to handle NULL (empty) parameters in this SP.

We can generate dynamic SQL in the code, of course, but then we should take measures against SQL injection attacks.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform