Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Making Dynamic Queries Static Expand / Collapse
Author
Message
Posted Thursday, July 11, 2002 2:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, February 16, 2005 10:13 AM
Points: 4, Visits: 1
Sorry, I should use this instead of my last post:

CREATE PROCEDURE sp_MySearch
@p1 varchar(50),
@p2 varchar(50)
As


select * from t
where
isnull(c1, isnull(@p1,'')) like case when len(isnull(@p1,'')) =0 then isnull(c1, '') else '%'+@p1+'%' end and
isnull(c2, isnull(@p2,'')) like case when len(isnull(@p2,'')) =0 then isnull(c2, '') else '%'+@p2+'%' end






Post #32601
Posted Monday, March 26, 2007 3:06 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Wednesday, November 14, 2012 12:06 PM
Points: 15, Visits: 131

Hi Leon,

Great article. I thnk even this solution would work:

 

IsNull(state,'') like IsNull(@State,'')

Or

state like IsNull(@state,state)+''

I am using this in a procedure and it seems to work fine.

 

Post #353996
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse