SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 LIKE statement in Report Builder 3 with parameters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nferri
Starting Member

USA
5 Posts

Posted - 02/15/2013 :  15:13:08  Show Profile  Reply with Quote
Hi, I am trying to add a LIKE statement to a query in report builder 3.0 with a parameter like the one below. It allows the user to input an ID and returns records that have that id in their list of IDs by using the like statement with wildcards.

SELECT
CORRIDOR.OBJECTID
,CORRIDOR.STATUS
,CORRIDOR.DIMENSION
,CORRIDOR.WIDTH
,CORRIDOR.ID
FROM
CORRIDOR
WHERE ID LIKE '%' + @ID + '%'

I get an error "Conversion Failed when Converting the varchar value '%' to data type int"

I am not sure why the wildcard is converting to int. my @ID parameter is text. Please help. Thanks!

James K
Flowing Fount of Yak Knowledge

3724 Posts

Posted - 02/15/2013 :  15:51:36  Show Profile  Reply with Quote
May be the ID column is INT? Try this to be safe on all sides, and then you can try removing one side or the other if you like to:
WHERE CAST(ID AS VARCHAR(32)) LIKE '%' + CAST(@ID AS VARCHAR(32)) + '%'
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000