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.







