Saturday, June 30, 2012

SQL - Filter Non-Alpha First Character


select COUNT(*) from tmp_audit_geographic where sel_city LIKE '[A-z]%'

select COUNT(*) from tmp_audit_geographic where sel_city NOT LIKE ISNUMERIC(sel_city)

select * from table
where ASCII(Name) NOT BETWEEN 65/* A */ and 90/* Z */
 AND ASCII(Name) NOT BETWEEN 97 /* a */ AND 122 /* z */

Wednesday, June 20, 2012

SQL - Select Query Limit

"LIMIT" in SQL Server

 

Syntax:

SELECT * FROM
( SELECT *, ROW_NUMBER() OVER (ORDER BY tablename) as row FROM tablename) a WHERE row > 1 and row <= 3


Example:


SELECT * FROM
( SELECT *, ROW_NUMBER() OVER (ORDER BY LogDateTime) as row FROM TblUserActiveLog ) a WHERE row > 1 and row <= 3