Hey allIts coming to the end of the day and I cannot seem to be able to work out how to get the syntax right when using the LIKE function in dynamic sql. Can someone please have a look and tell me what I am doing wrong:This is a somewhat shortened and simplified part of the query (and I cannot even get that to work):declare @sql varchar(2000)declare @recipientName varchar(20)set @recipientName = 'John'SET @sql = 'select * from DOcumentRecipient where DocumentRecipientName LIKE (''%''' + @recipientName + '''%'')'exec (@sql)
Error Message:Server: Msg 170, Level 15, State 1, Line 1Line 1: Incorrect syntax near 'John'.
Thank youHearty head pats