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.
| Author |
Topic |
|
headbuzz
Starting Member
11 Posts |
Posted - 2010-02-22 : 15:11:34
|
| Hi, Can someone help me out in figuring out the MS SQL equivalent of the following for mysql:CREATE EVENTe ON SCHEDULE EVERY 5 SECOND STARTS CURRENT_TIMESTAMP + INTERVAL 5 SECOND DOUPDATE names SET names.count=names.count+1; I'm basically trying to increment the values of all the rows under a particular column every 5 seconds. I could do it easily in mysql but when I'm trying to do it for SQL, I don't know what to do.I came up with an incomplete function that I'd maybe use, but I do not know how to trigger it every 5 seconds(the names of the variables do change). I wasted more than 3 days on this. I need some help desperately!!!CREATE FUNCTION lastday ( @joindate DATETIME)RETURNS INTBEGINDECLARE @referdate DATETIME DECLARE @count INT DECLARE @i DATETIMESET @referdate = CAST(YEAR(@joindate) AS VARCHAR(4)) + '/' + CAST(MONTH(@joindate) AS VARCHAR(2)) + '/01'SET @referdate=DATEADD(DD,-1,DATEADD(M, 1, @referdate))IF(day(@referdate)-day(@joindate)>=15) SET @count = 1ELSE SET @count = 0 WHILE (@i!=0)BEGINSET @referdate=DATEADD(SECOND,5,@referdate)SET @count=@count +1RETURN @count END |
|
|
russell
Pyro-ma-ni-yak
5072 Posts |
Posted - 2010-02-22 : 16:34:12
|
| http://msdn.microsoft.com/en-us/library/ms186273(SQL.90).aspx |
 |
|
|
|
|
|