Search This Blog

Friday, February 18, 2011

Extract hour, minute from date column Oracle

Oracle > Extract hour, minute from date column

SELECT
  to_char(column_date,'HH24') hh
  ,to_char(column,'mi') min
from
  table;




Wednesday, February 2, 2011

SQL Server Deadlocks

SQL Server > Deadlocking

Deadlocking occurs when

  •  two user processes have locks on separate objects and each process is trying to acquire a lock on the object that the other process has.

SQL Server identifies the problem and ends the deadlock by: 


  • automatically choosing one process and aborting the other process
  • allowing the other process to continue.

The aborted transaction is rolled back and an error message is sent to the user of the aborted process.
Generally, the transaction that requires the least amount of overhead to rollback is the transaction that is aborted.

Avoid deadlocking on your SQL Server:

  • Ensure the database design is properly normalized.
  • Have the application access server objects in the same order each time.
  • During transactions, don't allow any user input.
  • Avoid cursors.
  • Keep transactions as short as possible.
  • Reduce lock time.
  • If appropriate, reduce lock escalation by using the ROWLOCK or PAGLOCK.
  • Consider using the NOLOCK hint to prevent locking if the data being locked is not modified often.
  • If appropriate, use as low of an isolation level as possible for the user connection running the transaction.