try:CREATE PROCEDURE U_cofigcount_bak
AS
declare @configcount int
declare @wanzencount int
declare @shield int
declare @sql varchar(1000)
select @configcount=count(*) from U_restaurant where r_config=0
select @wanzencount=count(*) from u_restaurant where r_wanzen=0
select @shield=count(*) from u_restaurant where r_shield=1set @sql=''
set @sql='
update
u_config
set r_configcount='+@configcount+',
r_wanzencount='+@wanzencount+',
r_shieldcount='+ @shield
exec @sql
GO
AS
declare @configcount int
declare @wanzencount int
declare @shield int
declare @sql varchar(1000)
select @configcount=count(*) from U_restaurant where r_config=0
select @wanzencount=count(*) from u_restaurant where r_wanzen=0
select @shield=count(*) from u_restaurant where r_shield=1set @sql=''
set @sql='
update
u_config
set r_configcount='+@configcount+',
r_wanzencount='+@wanzencount+',
r_shieldcount='+ @shield
exec @sql
GO
如果说是数据表的话,哪有那么更新数据的呢
AS
declare @configcount int
declare @wanzencount int
declare @shield int
set @configcount=(select count(*) from U_restaurant where r_config=0)
set @wanzencount=(select count(*) from u_restaurant where r_wanzen=0)
set @shield=(select count(*) from u_restaurant where r_shield=1)
update
u_config
set r_configcount=@configcount,
r_wanzencount=@wanzencount,
r_shieldcount= @shield -- update 还应该有条件把
GO
楼主的update没有加参数,那么整表都会被update的哦,除非那个表里面只有一行,请楼主注意了。