Return to Snippet

Revision: 43875
at April 1, 2011 21:45 by kashif21


Initial Code
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
)

Initial URL

                                

Initial Description

                                

Initial Title
SQl Select cluase value conversion

Initial Tags
sql

Initial Language
SQL