umm
umm

Reputation: 13

Invalid column name '''

INSERT INTO #Prefix_PCAC_temp select rtrim(ltrim(replace(@str1,"'",null)))

in the above line it is showing error invalid column name '''.PLZ provide me any solution.

Upvotes: 1

Views: 579

Answers (1)

Andrey Gordeev
Andrey Gordeev

Reputation: 32499

Use this to prevent incorrect syntax error:

INSERT INTO #Prefix_PCAC_temp select rtrim(ltrim(replace(@str1,'''',null)))

However, if there is ' symbol in your @str1 variable, the value will become NULL. Most likely you want this:

INSERT INTO #Prefix_PCAC_temp select rtrim(ltrim(replace(@str1,'''','')))

The query above eliminates ' symbols from @str1 variable and inserts the value into the table

Upvotes: 1

Related Questions