A store procedure for microsoft sql to check win

July 15, 2008

This procedure use time… month and day

CREATE procedure sp_update_WinHands

@month as  nvarchar(10) ,
@day as nvarchar(10)
as

declare @win as float
declare @lose as float
DECLARE @hand INT
declare @query nvarchar(1000)

declare @check as int

set @check=( select count(tableid) from bethistory where month1=@month and day1= @day)

if ( @check=0 )
begin
insert into bethistory(month1,day1) values (@month,@day)
end

SET @hand = 1
WHILE (@hand <=12)
BEGIN

set @win = (select count(id)  from BetHeader
where datepart(m,dt)=@month and datepart(d,dt)=@day
and case when lasthand>@hand then 1 else 0 end=1)

set @lose = (select count(id)  from BetHeader
where datepart(m,dt)=@month and datepart(d,dt)=@day
and case when lasthand>@hand then 1 else 0 end=0)

if( @win=0 ) begin set @win=1 end

set @query= ‘update  bethistory set h’+cast(@hand as nvarchar(10))+’='+cast(@lose as nvarchar(10))+’.00/’+cast(@win as nvarchar(10))+’.00  where month1=’+@month+’ and day1= ‘+@day+”

exec ( @query )

SET @hand = @hand + 1
END

GO

Entry Filed under: Database, Script. Tags: , , , , , , , , , , .


Archives

Other

Categories

 

July 2008
M T W T F S S
« Jun   Aug »
 123456
78910111213
14151617181920
21222324252627
28293031  

Tags