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
 Analysis Server and Reporting Services (2005)
 SSRS like operator with parameter?

Author  Topic 

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2008-11-13 : 07:59:51
Hi, I'm struggling with adding a parameter in the like operator

SQL: select * from table where test like '%filter%'

SSRS: like '%@filter%'
I have tried: like '"*" & @filter & "*"'

Please Assist!

Regards

ismailc
Constraint Violating Yak Guru

290 Posts

Posted - 2008-11-13 : 08:47:45
Senior Collegue assisted & got me going:

like '%' + @filter + '%'
Go to Top of Page

tendai
Starting Member

2 Posts

Posted - 2011-08-17 : 09:32:40
i am trying to get the like operator to work using what was suggested but i dont seem to get it to work my query is as below
select a.warehouse as wse,d.description as warehouse,b.card_number as card_no,a.product as product,long_description as description,
expected_quantity as expected_qty,adjustment_quantit as variance,
expected_quantity+adjustment_quantit as actual_qty,current_cost as cost,adjustment_quantit*current_cost as value
from scheme.stockm a,scheme.sttakehm b,scheme.sttakedm c,scheme.stkwhm d
where a.product=c.product_code
and a.warehouse=b.warehouse
and b.card_number=c.card_number
and adjustment_quantit<>0
and b.card_number like '%' + @card_number + '%'
and d.warehouse in ('37','38')
and d.warehouse=a.warehouse
order by warehouse asc
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-18 : 04:30:05
what are you passing as values for @card_number?

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

Go to Top of Page

tendai
Starting Member

2 Posts

Posted - 2011-08-19 : 10:01:36
quote:
Originally posted by visakh16

what are you passing as values for @card_number?
i am passing 22 as the card_number

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



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-08-19 : 12:08:43
assuming @card_number is int you should make statement like

and b.card_number like '%' + cast(@card_number as varchar(10)) + '%'

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

Go to Top of Page
   

- Advertisement -