how to validate the input parameters before using in the static query?? SQL server 2005

Posted by Guru on Stack Overflow See other posts from Stack Overflow or by Guru
Published on 2010-04-05T15:29:40Z Indexed on 2010/04/05 15:33 UTC
Read the original article Hit count: 223

Filed under:
|
|

consider table1 with 2 columns.. table1: column1 int, column2 char

create procedure SP1(@col1,@col2) as begin select * from table1 where _ end

Question: User may enter valid input for either (col1 or col2) or (both col1 and col2).so i need to validate the user input and use those correct column(s) in the satic query.

eg: if both inputs are correct then, the query will be. select * from table1 where column1=@col1 and column2 =@col2 if only col2 is valid and col1 is not a valida one, then select * from table1 where column2=@col2

how to validate the input parameters before using in the static query?? in sql server 2005

© Stack Overflow or respective owner

Related posts about sql

Related posts about server