TRANSACT-SQL Tips
1. Get only date part for comparing.
FLOOR(CAST(GETDATE() AS FLOAT))
2. Paging
DECLARE @PageNum int
DECLARE @PageSize int
SET @PageNum = 2
SET @PageSize = 20;
WITH cte AS
(
SELECT tbl.*, ROW_NUMBER() OVER(ORDER BY Article_Id) AS RowNum
FROM SomeTable tbl
)
SELECT * FROM cte
WHERE RowNum BETWEEN (@PageNum-1) * @PageSize AND @PageNum * @PageSize;