1: 2: 3: 4: 5:
declare @var varchar(10),@search varchar(50) set @var ='a%' set @search = 'where name like ''' +@var + ''' ' exec('select * from table ' + @search)