hierarchyid GetAncestor returns a logical ancestor path. Its zero-distance result is the original node, while a request beyond the root returns NULL.
OLEDB Wait Stats: Linked Servers and Remote Calls
OLEDB wait stats measure the time SQL Server spends in calls to an OLE DB provider, and that usually means a linked server. On Night 23 at the Clipboard Diner, the pie case is empty and Jules crosses the street for every slice. Learn how to find the waiting session, how OPENQUERY filters on the remote side, and when to keep a local copy instead.
MSQL_XP Wait Stats: Extended Procedures and External Code
MSQL_XP wait stats measure the time a query waits while an extended stored procedure such as xp_cmdshell or xp_dirtree runs. On Night 20 at the Clipboard Diner, an outside caterer takes over one station behind a curtain. Then two queries show you which session is waiting and which procedure it called, and the fixes move that work outside SQL Server.
PREEMPTIVE Wait Stats: Calls Outside SQL Server
PREEMPTIVE wait stats record the time a task spends in code outside SQL Server, such as a call into Windows. On Night 19 at the Clipboard Diner, Kit picks up the wall phone to town hall and steps off the kitchen’s schedule. Then two queries find the preemptive waits that matter on your server.
EXISTS: A Row Containing NULL Still Exists
EXISTS answers whether qualifying rows exist. Keep missing values separate from missing rows and preserve the intended correlation.
Sorting Correctly: Collation and ORDER BY
Collation and ORDER BY decide case, accent, and text-number order; choose rules explicitly when one report needs different sorting.
Text Equality: Trailing Spaces Can Compare as Equal
Text equality can match different stored strings. Check byte length and complete representation when exact identity belongs to the contract.




