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
 General SQL Server Forums
 New to SQL Server Programming
 addind wildcard to a variable

Author  Topic 

shebert
Yak Posting Veteran

85 Posts

Posted - 2009-08-03 : 16:05:03
Hi All
any one know how to add a wildcard to a variable?

example

declare @wild int

set @wild=16

select * from anytable where tableid like @wild+'%'

I want all records in anytable begining with 16

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-08-03 : 16:11:14
what datatype is [tableid] ?

Is it INT like your @wild variable? So you want any id like 16, 162, 1600034?
Or is it some type of varchar? If so just make your variable varchar then you statement would work.

Be One with the Optimizer
TG
Go to Top of Page

shebert
Yak Posting Veteran

85 Posts

Posted - 2009-08-03 : 16:20:20
I bow to your SQL wisdom....all set
Go to Top of Page
   

- Advertisement -