declare @sql nvarchar(255) set @sql = 'select * from sys.objects where name like ' + quotename('%', '''') + '+' + quotename('sysdiagrams', '''') + '+' + quotename('%', '''') print @sql exec(@sql) --select * from sys.objects where name like '%'+'sysdiagrams'+'%'