MSSQL 2005 Dynamic PIVOT

Here’s a method of generating a dynamic pivot of a dataset. It first generates the columns as a string (“[ColumnHeader0],[ColumnHeader1],[ColumnHeader2], …” format), builds a dynamic SQL string and executes it using the PIVOT expression. From the code below, the @cols variable is generated by using the FOR XML PATH expression. …

Show Oracle Locks

If you’re having issues with locks in Oracle, here’s a way to show what sessions have locks on which objects. select s.osuser “O/S-User”,   s.username “Ora-User”,   s.sid “Session-ID”,   s.serial# “Serial”,   s.process “Process-ID”,   s.status “Status”,   l.name “Obj Locked”,   l.mode_held “Lock Mode”,   count(*) from v$session s, dba_dml_locks l, v$process p where l.session_id = …