【发布时间】:2010-03-30 07:25:31
【问题描述】:
声明@sqlCommand varchar(1000) 声明 @columnList varchar(75) 声明@city varchar(75) 声明@region varchar(75) SET @columnList = '名字,姓氏,城市' SET @city = '''伦敦''' SET @region = '''南''' SET @sqlCommand = 'SELECT' + @columnList +' FROM dbo.employee WHERE City = ' + @city 和 'region = '+@region --and 'region = '+@region 打印(@sqlCommand) 执行(@sqlCommand)
当我运行这个命令时,我得到一个错误
消息 156,级别 15,状态 1,第 8 行 关键字“and”附近的语法不正确。
非常感谢您的帮助
【问题讨论】:
标签: sql-server