/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
SELECT AuditID, LoginName, LoginDatetime, IPAddress, CASE IsAuthenticated WHEN 1 THEN 'Yes' ELSE 'No' END AS IsAuthenticated, ROW_NUMBER() OVER (ORDER BY CASE WHEN @strSortCol = 'AuditID ASC' THEN AuditID END, CASE WHEN @strSortCol = 'AuditID DESC' THEN AuditID END DESC, CASE WHEN @strSortCol = 'LoginName ASC' THEN LoginName END, CASE WHEN @strSortCol = 'LoginName DESC' THEN LoginName END DESC, CASE WHEN @strSortCol = 'LoginDatetime ASC' THEN LoginDatetime END, CASE WHEN @strSortCol = 'LoginDatetime DESC' THEN LoginDatetime END DESC, CASE WHEN @strSortCol = 'IPAddress ASC' THEN IPAddress END, CASE WHEN @strSortCol = 'IPAddress DESC' THEN IPAddress END DESC, CASE WHEN @strSortCol = 'IsAuthenticated ASC' THEN IsAuthenticated END, CASE WHEN @strSortCol = 'IsAuthenticated DESC' THEN IsAuthenticated END DESC ) AS RowNum, COUNT(*) OVER() AS [TotalRows] FROM AuditLogin WHERE (@strUserName = '' OR LoginName LIKE '%' + @strUserName + '%') AND LoginDateTime >= @dtmFromDate AND LoginDateTime <= @dtmToDate )