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 |
kshahzad
Starting Member
45 Posts |
Posted - 2013-07-04 : 01:15:45
|
I want to modify this query to return row count DECLARE @dCurrentTimeDATETIMEDECLARE @dCurrentTimeMinus5DATETIMESET @dCurrentTime=GETDATE()SET @dCurrentTimeMinus5=DATEADD(minute,-5, @dCurrentTime)--Return lIDS for only sessions last accessed in the last 5 minutesSELECT lID,MAX(dLastAccessed)FROM SessionState_VariablesWHERE dLastAccessedBETWEEN @dCurrentTimeMinus5AND @dCurrentTimeGROUPBY lIDORDERBY 2DESC |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-04 : 01:24:11
|
[code]DECLARE @dCurrentTimeDATETIMEDECLARE @dCurrentTimeMinus5DATETIMESET @dCurrentTime=GETDATE()SET @dCurrentTimeMinus5=DATEADD(minute,-5, @dCurrentTime)--Return lIDS for only sessions last accessed in the last 5 minutesSELECT COUNT(*)FROM SessionState_VariablesWHERE dLastAccessed =(SELECT MAX(dLastAccessed)FROM SessionState_VariablesWHERE dLastAccessed BETWEEN @dCurrentTimeMinus5AND @dCurrentTime)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
kshahzad
Starting Member
45 Posts |
Posted - 2013-07-04 : 19:12:05
|
this worked thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-07-05 : 01:26:57
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|