|
Posted by Erland Sommarskog on 06/05/05 01:00
[posted and mailed, please reply in news]
js (androidsun@yahoo.com) writes:
> I have a stored procedure named "processInventory" like the following.
> Depending on the passed in parameters, I would like to add a WHERE
> clause for "select" action. For example, if any varchar type of
> parameter is passed in, the where clause would use "LIKE" operator. For
> example, "Select * from Main where [s/n] like @Serial. All other types
> will use "=" operator. For example, "Select * from Main where MAKE =
> @Make and Type = @type".
> How could this be achieved? Thanks.
I have a longer article on the topic on
http://www.sommarskog.se/dyn-search.html.
Since you are into UPDATE, I would careful with using dynamic SQL
because of the permissions issues.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Navigation:
[Reply to this message]
|