-2

Below line is returning me the value with single quote.

set @SearchStr2= upper(QUOTENAME('%''' + @SearchStr + '''%','''') )COLLATE SQL_Latin1_General_CP1_CS_AS;

Actual Output : '%'NM'%'

Expected Output : '%''NM''%' -- Need 2 single quotes before and after %

Squirrel
  • 23,507
  • 4
  • 34
  • 32
Indhu
  • 1

1 Answers1

0

I'm not exactly sure what you are targeting. Assuming your current code's @SearchStr = 'NM'. Your current code should return your "Expected Output".

If that isn't what you're expecting, just add more single quotes till you get what you want.

Example:

SELECT UPPER(QUOTENAME('''%''' + 'NM' + '''%''','''') )COLLATE SQL_Latin1_General_CP1_CS_AS

I added more 2x single quotes before and after the %'s and that added an additional single quote on the return screen. '''%''NM''%'''

QuestionGuyBob
  • 303
  • 1
  • 10