July 20, 2008 at 8:34 am
I need to return users who have logged in within the last 30 minutes.
Getting a SQL Error on the > operator. HELP!
I am getting this error......
------------------------------------------------
Msg 170, Level 15, State 1, Procedure ISF_Operations_GetAllUsers, Line 16
Line 16: Incorrect syntax near '>'.
This is the procedure....
------------------------------------------------
ALTER PROCEDURE [dbo].[ISF_Operations_GetAllUsers]
AS
BEGIN
SET NOCOUNT ON;
SELECT
PE.FirstName, PE.LastName, U.UserId,
PE.HomePhone, PE.MobilePhone, PE.FaxPhone,
PE.HomeCity, PE.HomeState, PE.HomeZip, PE.IsProfileUpdated, PE.EmployeeStatus,
PE.Extension, PE.OfficeNumber, M.LastLoginDate,
CASE UserIsOnline
WHEN M.LastLoginDate > DATEADD(n,-30,getdate()) THEN 'True'
ELSE 'False'
END
FROM aspnet_Users U
INNER JOIN aspnet_Membership M
ON U.UserId = M.UserId
INNER JOIN ISF_ProfileEmployee PE
ON U.UserId = PE.UserId
ORDER BY PE.LastName
END
July 20, 2008 at 9:10 am
You're mixing the two styles of CASE:
CASE column|@val|const
WHEN column|@val|const THEN column|@val|const
WHEN column|@val|const THEN column|@val|const
ELSE column|@val|const
END
or
CASE
WHEN Boolean Expression THEN column|@val|const
WHEN Boolean Expression THEN column|@val|const
ELSE column|@val|const
END
Try this:
CASE WHEN M.LastLoginDate > DATEADD(n,-30,getdate()) THEN 'True'
ELSE 'False'
END AS UserIsOnline
-Eddie
Eddie Wuerch
MCM: SQL
July 20, 2008 at 9:15 am
Thanks Eddie, that worked!
I really appreciate the help. Happy Sunday to you.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply