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: author-pinal, msbuild, sql-authority, sql-backup-and-restore, sql-data-storage, sql-datetime, sql-documentation, sql-download, sql-query, sqlauthority-news, t-sql.
Trackback this post | Subscribe to the comments via RSS Feed