TSQL-Scripts icon indicating copy to clipboard operation
TSQL-Scripts copied to clipboard

Update PMDB.Create_Database_Backup.sql

Open Imran-imtiaz48 opened this issue 10 months ago • 0 comments

Improvements Made:

  1. Used SYSNAME instead of VARCHAR(50) for database names — it’s more semantically accurate and flexible.
  2. Formatted timestamp using FORMAT() for readability.
  3. Better username extraction using PARSENAME() to get only the login name.
  4. Improved folder logic with fallback/default behavior.
  5. Added IF NOT EXISTS to create schema safely.
  6. Included WITH INIT, STATS = 10 for better control and visibility during the backup process.
  7. Added error handling to notify if the DB doesn’t exist.
  8. Readable and reusable variable names to make the procedure self-documenting.

Imran-imtiaz48 avatar Apr 06 '25 01:04 Imran-imtiaz48