Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

I want to insert the resultset into new table i created

$
0
0

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



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>