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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 search condition handling in proc

Author  Topic 

paritosh
Starting Member

42 Posts

Posted - 2012-07-03 : 10:44:46
hi all ,

i want to create procedure according to below mention criteria


create procedure abc (name varchar (50),
name2 varchar (50),
name3 varchar (50),
name4 varchar (50),
)
if i want to create query for above in parameter condition
so how can done for this senario.

how to handle this problem
problem is

if name is null and name2 is null and name3 is null and name4 is null
then query fire select * from table
else if name is not null and name2 is null and name3 is null and name4 is null
then query fire select * from table where name1 like '%s%'

else if name is not null and name2 is not null and name3 is null and name4 is null
then query fire select * from table where name1 like '%s%' and name2 like '%p%' and so on ..


how to do this simple condition basis append query


thanks in advance




webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-03 : 11:12:03
http://sqlinthewild.co.za/index.php/2009/03/19/catch-all-queries/


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-03 : 19:12:00
why are there columns like name1,name2 etc? have you heard about normalisation?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -