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)
 passing param for like '%'

Author  Topic 

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2007-12-03 : 14:57:03
Hi,

I'm attempting to write the below SP, but not sure how to go about integrating the passed parameter into the "LIKE 'text%'" part.

can anyone tell me how this should really look?
Thanks!
mike123

CREATE PROCEDURE [dbo].[select_nameOnline_autoPopulator]
(
@nameOnline varchar(15)
)
AS SET NOCOUNT ON

SELECT nameOnline FROM tblUserDetails WHERE nameOnline like '@nameOnline%' and active =1

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-12-03 : 14:59:05
SELECT nameOnline FROM tblUserDetails WHERE nameOnline like @nameOnline + '%' and active =1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-12-03 : 14:59:25
WHERE nameOnline LIKE @nameOnline + '%' AND active = 1



Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

stormcandi
Starting Member

46 Posts

Posted - 2007-12-03 : 18:31:23
Where nameOnline like (@nameOnline + '%')
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-12-03 : 18:45:41
quote:
Originally posted by stormcandi

Where nameOnline like (@nameOnline + '%')



How is that different from what Peter and I posted? You don't need the parenthesis in this situation.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

mike123
Master Smack Fu Yak Hacker

1462 Posts

Posted - 2007-12-04 : 04:59:11
thank you !! :)

Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-12-04 : 07:18:12
How is that different from what Peter and Tara posted? You don't need the parenthesis in this situation.

see, its catching!!! its an epidemic! I better go get some meds for it....

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page
   

- Advertisement -