Hello -
I have a report based on a query that currently uses the = operator and I'd like to change it to the LIKE operator and allow a wildcard...using the %.
So...from something like, "....WHERE zipcode = @.ZipCode" to "...WHERE zipCode = @.zipCode plus the wildcard character.
Is this possible?
Thanks,
- will
You cannot do it direcly from query , You can write procedure and then call this procedure from report.
alter procedure TestReport(
@.param varchar(20)
)
as
declare @.SQLstring as nvarchar(200)
set @.SQLstring='select getdate() where zipcode like ''%'+@.zipcode+'%'''
exec sp_executesql @.SQLstring;
|||Will Durning wrote: Hello -
I have a report based on a query that currently uses the = operator and I'd like to change it to the LIKE operator and allow a wildcard...using the %.
So...from something like, "....WHERE zipcode = @.ZipCode" to "...WHERE zipCode = @.zipCode plus the wildcard character.
Is this possible?
Thanks,
- will
You can very well achieve this in the query itself. Eg: select * from <table-name> where <column-name> like '%' + @.column-name + '%'
|||Thanks for the replies.
I ended up using a stored procedure and just concatenate the '%' to the incoming parameter. I could not get it to work with an inline sql query in my report....and besides, I was planning on using stored procs anyway.
No comments:
Post a Comment