I type Code in SP
Exec ('INSERT INTO XXX (A,B,C)
Select A,'Y8',C From YYY
GROUP BY A,B');
But it has error, Value 'ABC' not correct
Why, Thanks
William
Exce SP Code have error
Server: Msg 207, Level 16, State 3, Line 1
Invalid column name 'Y8'.
Try this:
EXEC ('INSERT INTO XXX (A,B,C) Select A,''Y8'',C From YYY GROUP BY A,B');
Chris
|||If you want to use the single quote (‘) with in the sql string you have to use the escape sequence.
Many languages support \ as escape sequential char. But in sql server the same char need to be repeated (twice).
Example:
Select @.a = 'Sql Server''s'
So you have to change your query as follow as,
Exec (
'INSERT INTO XXX (A,B,C)
Select A,''Y8'',C From YYY
GROUP BY A,B'
);
No comments:
Post a Comment