SqlStarter (8/24/2016)
Hii need to find whether a set of words for ex. SET NOCOUNT ON in a text. in text it may be SET NOCOUNT ON (with lot of speces in between those words) .
any suggestion on how to achieve this?
declare @txt varchar (500) = 'create proc proc_name as begin set nocount on select 1 end'
declare @src_text varchar(50)='set nocount on'
SELECT 'EXISTS' WHERE @txt like '%'+@src_text+'%
Why not take out all the spaces from both, and test for the string SETNOCOUNTON ?
Using your variables
SELECT 'EXISTS'
WHERE REPLACE(@txt,space(1),space(0)) LIKE
'%'+REPLACE(@src_text,space(1),space(0))+'%'
__________________________________________________
Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills