Write, refactor, and review complex high-performance T-SQL, including stored procedures, set-based logic, window functions, and dynamic SQL written to be safe from SQL injection. Apply deep knowledge of SQL Server internals (storage engine, query optimizer, SQLOS, memory, transaction log, tempdb) to diagnose complex production issues.