SqlCommand s2 = new SqlCommand();
s2.CommandText = @"declare @sql nvarchar(max);
set @sql = 'select sys_RespNum from ' + quotename(@tableName) + 'where' + 'respid' + 'in' + '(' + @emails + ')';
exec (@sql);
代码有什么问题?我收到错误消息:
@emails附近的语法不正确
答案 0 :(得分:3)
您错过了空间
set @sql = 'select sys_RespNum from ' + quotename(@tableName) + ' where ' + ' respid ' + ' in ' + '( ' + @emails + ' )';
exec (@sql);