Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
Hi,I get a field value with a query and the value is this: @myvar = '%.ABC'Can I then say this: Select Y from table where X Like @myvarExpecting the % in @myvar to act as wildcard?If not, how can I do this?Thanks!--PhB
RyanRandall
Master Smack Fu Yak Hacker
1074 Posts
Posted - 2009-12-02 : 12:05:55
You mean like this?
declare @table table (x varchar(9), y int)insert @table select 'XYZ.ABC', 1union all select '.ABC', 2union all select 'ABC.ABD', 3declare @myvar varchar(9)set @myvar = '%.ABC'Select Y from @table where X Like @myvar
Ryan Randall Solutions are easy. Understanding the problem, now, that's the hard part.