Skip to content

Instantly share code, notes, and snippets.

@kiyokura
Last active December 28, 2015 01:21
Show Gist options
  • Save kiyokura/c8c85bd789185eb070d9 to your computer and use it in GitHub Desktop.
Save kiyokura/c8c85bd789185eb070d9 to your computer and use it in GitHub Desktop.
EXECUTEで実行できるのと出来ないのと
DECLARE @arg varchar(MAX) = 'HOGEHOGE'
DECLARE @A varchar(MAX) = 'SELECT ''' + LEFT(@arg,4) + ''' as col1'
-- col1:HOGEで結果が返る
EXECUTE(@A)
-- エラーで実行できない
EXECUTE('SELECT ''' + LEFT(@arg,4) + ''' as col1')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment