create proc Statistic
@companyname nvarchar(100),
@total_company int=0 output
as
declare
@countcompany nvarchar(10)
set @countcompany= 'select @a1=count(1) from company where companyname= '[email protected]
exec sp_executesql @countcompany ,N '@a1 int output ',@total_company output
大家看看有什么问题,
执行后结果总为0
------解决方案--------------------
create proc Statistic
@companyname nvarchar(100),
@total_company int=0 output
as
begin
declare @countcompany nvarchar(10)
set @countcompany=N 'select @a1=count(1) from company where companyname= ' ' ' + @companyname + ' ' ' '
exec sp_executesql @countcompany ,N '@a1 int output ',@total_company output
end
go
------解决方案--------------------
--try
create proc Statistic
@companyname nvarchar(100),
@total_company int output
as
select @total_company=count(1) from company
where [email protected]
return
go