Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help in Stored Procedure

Author  Topic 

phi7ip
Starting Member

3 Posts

Posted - 2010-04-26 : 10:29:55
can you please check this script
in RanGame1.GuildInfo i have a column named GuLvl (int)
in RanGame1.GuildRegion i have column named intime (Datetime)

when this script run it should check the date & time in intime column
and comapre to curent date& time if it is more than 55mins it just ignore this script but if less than 55mins then deduct 1 from Gulvl
can you help me thanks...


use [Rangame1]
declare @time datetime
SELECT @time = intime FROM GuildRegion WHERE RegionID=@RegionID


IF DATEDIFF(minute, intime, GETDATE()) < 55
begin
Update [GuildInfo] set
[GuildInfo].GuLvl = [GuildInfo].GuLvl - 1
where
[GuildInfo].GuNum = @GuNum
end

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-04-26 : 11:32:04
Only one small change:

use [Rangame1]
declare @time datetime
SELECT @time = intime FROM GuildRegion WHERE RegionID=@RegionID


IF DATEDIFF(minute, @time, GETDATE()) < 55
begin
Update [GuildInfo] set
[GuildInfo].GuLvl = [GuildInfo].GuLvl - 1
where
[GuildInfo].GuNum = @GuNum
end

and obviously you are passing @GuNum in...
Go to Top of Page

phi7ip
Starting Member

3 Posts

Posted - 2010-04-26 : 11:38:31
still not working :(
thank you for your reply
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-04-26 : 12:01:14
Whats the error?
Go to Top of Page

phi7ip
Starting Member

3 Posts

Posted - 2010-04-26 : 12:21:53
its just not deducting from gulvl
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-27 : 00:32:15
i cant understand the logic. howzz guildinfo related to guildregion?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-04-27 : 04:17:17
Can you please run the below and post the results (the exact results you get in the Results pane).

use [Rangame1]
declare @time datetime
SELECT @time = intime FROM GuildRegion WHERE RegionID=@RegionID
Select @time, @GuNum, @RegionID
select * from [GuildInfo] where [GuildInfo].GuNum = @GuNum

IF DATEDIFF(minute, @time, GETDATE()) < 55
begin
Update [GuildInfo] set
[GuildInfo].GuLvl = [GuildInfo].GuLvl - 1
where
[GuildInfo].GuNum = @GuNum
end
Go to Top of Page
   

- Advertisement -