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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 sp help

Author  Topic 

ann
Posting Yak Master

220 Posts

Posted - 2009-04-11 : 11:31:09
hi

I am trying to get the LIKE clause to work in my sp - in specific, I have a param. for the like clause @title varchar(50) = '%%'.

what I am trying to do, is if I pass in a param. I want the like clause to do a standard where with like. If I don't pass in a param. I want it to return all values. The all values works, but it returns nothing when I pass in a value.

here is a sample of what the sp looks like:

Create Procedure someSP

@title varchar(50) = '%%'

As

Begin

Select * from sometable
where title like @title

Again, if I pass no param - it returns all results the way it should - if I pass a param, it returns nothing.

Can anyone help?

Thanks

ann
Posting Yak Master

220 Posts

Posted - 2009-04-11 : 11:57:20
Never mind I figured it out - I wasn't adding the % to my param.

sigh...
Go to Top of Page
   

- Advertisement -