how to validate the input parameters before using in the static query?? SQL server 2005
- by Guru
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