Declare @Temp1 as nvarchar(max) = '' Declare @Temp2 as nvarchar(max) = '' If @Temp1 like @Temp2 + '%' Print 'Yup'
Why does this not work? I don't get the "yup" message.
This doesn't work because the brackets in the string have a special function in a LIKE statement - items between the brackets constitute a set of values that the singular character at the specified position matches. Your original pattern looks for a 1,0,4, or 2 followed by a 1 or an 0. To make this work, you should have a pattern like this:
Declare @Temp2 as nvarchar(max) = '[10004120][1100]'