Create Proc P_UpdateIP
@username varchar(20)
as
begin
if exists (select 1 from CountIP where username=@username)
Begin
Update CountIP
set ipcount=T.CountIP
from
(select CountIP=count(A.ip)
From TodayIp A,CountIP B where A.username=B.username and A.username=@username
)T
End
Else
Begin
Insert into CountIP(username,ipcount)
select @username,count(A.ip) from TodayIp where username=@username
End
end
@username varchar(20)
as
begin
if exists (select 1 from CountIP where username=@username)
Begin
Update CountIP
set ipcount=T.CountIP
from
(select CountIP=count(A.ip)
From TodayIp A,CountIP B where A.username=B.username and A.username=@username
)T
End
Else
Begin
Insert into CountIP(username,ipcount)
select @username,count(A.ip) from TodayIp where username=@username
End
end
@username varchar(20)
as
begin
if exists (select 1 from CountIP where username=@username)
Begin
Update CountIP
set ipcount= ipcount + T.CountIP
from
(select CountIP=count(A.ip)
From TodayIp A,CountIP B where A.username=B.username and A.username=@username
)T
End
Else
Begin
Insert into CountIP(username,ipcount)
select @username,count(ip) from TodayIp where username=@username
End
end
Create proc sp_textas select count(ip) as ipct,username into #temp from TodayIp group by username
update CountIP set ipcount=ipcount+ipCt from select A.* from #temp A leftjoin CountIP B on A.username=B.username insert into CountIP (username ,ipcount )
select username,count(ip) from TodayIp B
where not exists(select * from CountIP B where A.username=B.username)
drop table #temp
go
Select username,count(ip) ic into tempTable from todayIP group by username
update countIP set ipcount = ipcount + tempTable.ic from tempTable where countip.username = tempTable.username
insert into countIP (username, ipcount) select * from tempTable where username not in (select username from countIP)
drop table temptable
delete from todayip
GO
as
select username, cnt=count(ip) into # from TodayIp group by username
update a set ipcount=a.ipcount + b.cnt
from CountIP a, # b
where a.username = b.username
insert CountIP select * from # a
where not exists(
select * from CountIP where username=a.username)
create proc T_proc
as
update CountIP set ipcount=Today.ipcount
from
CountIP,(select username,count(distinct ip) as ipcount from TodayIp group by username) Today
where
CountIP.username=Today.usernameinsert CountIP
select Today.*
from (select username,count(distinct ip) as ipcount from TodayIp group by username) Today
where Today.username not in(select username from CountIP)
as
update CountIP set ipcount=ipcount+Today.ipcount
from
CountIP,(select username,count(distinct ip) as ipcount from TodayIp group by username) Today
where
CountIP.username=Today.usernameinsert CountIP
select Today.*
from (select username,count(distinct ip) as ipcount from TodayIp group by username) Today
where Today.username not in(select username from CountIP)