Incorrect syntax near ']'.?

后端 未结 3 570
误落风尘
误落风尘 2021-01-16 04:58

I have done some debugging on my sql and I cant figure out the maddening error I am getting I have narrowed it down to a couple of lines which I cant see what the problem is

3条回答
  •  再見小時候
    2021-01-16 05:25

    You're missing an opening square bracket here:

    ... ') SELECT ' + @cols2 + ']' + ' FROM ...
    

    Furthermore I would recommend you switch to using the QuoteName() function instead:

    ... ') SELECT ' + QuoteName(@cols2) + ' FROM...
    

提交回复
热议问题