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 2000 Forums
 SQL Server Development (2000)
 LIKE '%@VARIABLE%' help

Author  Topic 

hueby
Posting Yak Master

127 Posts

Posted - 2006-03-21 : 12:01:22
Hi all, I'm declaring a variable in my SP and bringin that value through VB.Net and CR. Now, I need to place this @POnumber in a LIKE statement as shown below. It does not seems to work though. Before I start troubleshooting everything else, is this correct/possible in a MS SQL SP?

CREATE PROCEDURE [xspInvoiceLookup] (@POnumber VARCHAR(25)) AS

SELECT *
FROM tablename
where blahblah LIKE '%@POnumber%'

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-03-21 : 12:06:37
Try this:

where  blahblah LIKE '%'+@POnumber+'%'


CODO ERGO SUM
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-22 : 00:59:22
or

Where charindex(@POnumber,blahblah)>0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-03-22 : 01:43:28
Your column names sound like the data our clients store in our databases!

Kristen
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-22 : 03:00:18
quote:
Originally posted by Kristen

Your column names sound like the data our clients store in our databases!

Kristen




Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -