I have this query running perfectly fine and the result set looks like this
NumberRows Time_stamp
----------- ------------------------------------------------------
940 2013-07-11 18:00:00.357
Now i want to insert these two columns values in a new table.
i cant figure out how can i do this.
DECLARE @dCurrentTime DATETIME
DECLARE @dCurrentTimeMinus5 DATETIME
--Declare @counttotal int
SET @dCurrentTime = GETDATE()
SET @dCurrentTimeMinus5 = DATEADD(minute, -5, @dCurrentTime)
--insert into UsersLoggedIn (NumberRows,@dCurrentTime);
SELECT Count(*) As NumberRows, @dCurrentTime as Time_stamp
FROM (
SELECT lID
FROM SessionState_Variables
WHERE dLastAccessed BETWEEN @dCurrentTimeMinus5 AND @dCurrentTime
GROUP BY lID
) As SessionsTable
Regards
k