SQL Server 2008 adds SYSDATETIMEOFFSET, which returns the current system date time along with its time offset from GMT. One line shows how.
How to Calculate Age Correctly in SQL Server
Calculate Age in SQL Server by counting completed birthdays, not calendar years. This post compares DATEDIFF, a DATEADD correction and a compact integer version on a bike club table, handles February 29 birthdays and ends with a reusable function for age on any date.
SQL SERVER – SQL SERVER – Simple Example of Recursive CTE – Part 2 – MAXRECURSION – Prevent CTE Infinite Loop
Can you stop a recursive CTE from running forever? Yes. Use the MAXRECURSION option to limit it, and see what happens when the limit is too low.
SQL SERVER – Simple Example of Recursive CTE
A simple example of Recursive CTE in SQL Server, using AdventureWorks to walk the hierarchy of managers and employees, with each part explained.
SQL SERVER – mssqlsystemresource – Resource Database
What is mssqlsystemresource? It is the Resource Database, a read only database of system objects that makes upgrading SQL Server much easier.
Pagination With OFFSET and FETCH
OFFSET and FETCH make page-number queries readable, but deep pages scan past prior rows; keyset pagination keeps the next page focused.
NULLIF Denominators: Keep Zero and Missing Values Visible
NULLIF denominators turn zero into NULL for a deliberate division policy. This complete example keeps zero, missing inputs and integer truncation visible beside the decimal result.
SQL SERVER – DBCC SHRINKFILE Takes Long Time to Run
Why does DBCC SHRINKFILE take so long when index rebuilds run faster? It is single threaded. Rebuild indexes first and the shrink takes less time.
SQL SERVER – 2005 -Track Down Active Transactions Using T-SQL
Want to track down active transactions in your database? One simple DMV query on sys.dm_tran_session_transactions returns them in SQL Server 2005.
SQL SERVER – Introduction to Log Viewer
The SQL Server 2005 Log Viewer shows SQL Server error logs, Agent logs, Database Mail and Windows event logs in one place, ready to filter and export.










