表:t id tme ip cishu sql语句(): create proc p @ip varchar(50), @time varchar(50), @cishu int output as declare @counts int declare @count2 int Select @count2=count(*) from t where id=1 if @count2<=0 begin insert into t values(@ip,@time,1) end else begin select @counts=cishu from t where ip like @ip and id=1 or tme like @time and id=1 if @counts>0 begin update t set ip=@ip,tme=@time,cishu=@counts+1 where id=1 end end select @cishu=cishu from t where id=1 go drop proc p 执行 declare @cc int exec p '192.168.1.2','2010.02.04' ,@cc output select @cc