我的存储过程代码如下:if(@CaId=-111 and @DaId=-111)
begin
Declare @strSql3 nvarchar(1500)
set @strSql3='select '+ @cId+'=Count(CoId) from House'
+@st
exec (@strSql3)
end
可运行时老提示:
在将 varchar 值 'select ' 转换成数据类型 int 时失败
我该如何正确写?
begin
Declare @strSql3 nvarchar(1500)
set @strSql3='select '+ @cId+'=Count(CoId) from House'
+@st
exec (@strSql3)
end
可运行时老提示:
在将 varchar 值 'select ' 转换成数据类型 int 时失败
我该如何正确写?
begin
Declare @strSql3 nvarchar(1500)
set @strSql3='select '+ convert(varchar(10),@cId)+'=Count(CoId) from House'
+@st
exec (@strSql3)
end
begin
Declare @strSql3 nvarchar(1500)
set @strSql3='select @cId=Count(CoId) from House'+@st
exec sp_execute @strSql3, N'@cId int out', @cId output
--exec (@strSql3)
end
begin
Declare @strSql3 nvarchar(1500)
set @strSql3='select @cId=Count(CoId) from House'+@st
exec sp_executesql @strSql3, N'@cId int out', @cId output
--exec (@strSql3)
end
(@cId int output,
@st nvarchar(500),
@La nvarchar(50),
@CaId int,
@DaId int
)
ASif(@CaId=-111 and @DaId=-111)
begin
Declare @strSql3 varchar(1500)
set @strSql3='select @cId=Count(CoId) from House'
exec sp_execute @strSql3, N'@cId int out', @cId output
end