我正在尝试获取特定行的列的值,但出现以下错误。我不知道有什么问题。这是我的sql查询:
declare @Service_Table varchar(30),
@Ser_Id tinyint,
@sql nvarchar(100),
@Service_State tinyint
SET @Service_Table='Third_Party_Assistance'
set @Ser_Id = 2
SET @sql = 'SELECT ' + @Service_State + '= Service_State_Id FROM dbo.' +
quotename(@Service_Table) + ' WHERE Service_Id = ' +
convert(varchar,@Ser_Id) + 'AND Service_State_Id <> 4'
EXEC sp_executesql @sql