-1
這工作:當我在撇號之前刪除一些空格時,爲什麼字符串連接失敗?
DECLARE @query as nvarchar(200);
SET @query = 'SELECT j.job FROM ' + '' + 'job as j';
EXEC sp_executesql @query
...但是這不工作(輸出誤差是Incorrect syntax near the keyword 'as', pointing to the first line
):
DECLARE @query as nvarchar(200);
SET @query = 'SELECT j.job FROM' + '' + 'job as j'; -- removed the white space after the word FROM
EXEC sp_executesql @query
這是爲什麼?
打印出來的查詢。 。 。 'FROMjob as j'不是有效的SQL。 –