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 9 months ago • 0 comments

The script has been improved with several enhancements: • Added error handling using TRY...CATCH to catch and display issues during execution. • Improved string handling with NVARCHAR for better Unicode support and used sp_executesql for safer dynamic SQL execution. • Removed hardcoded backup paths, adding flexibility to set the backup folder path based on the server. • Enhanced readability by grouping related PRINT statements and removing unnecessary debug outputs. • Improved protection against SQL injection by constructing SQL statements safely. Next Steps suggested: • Standardize backup path by replacing hardcoded values with a configuration table or parameter. • Add proper logging to record backup success or failure for auditing. • Ensure the procedure runs with least privilege necessary for security. You can view and discuss this issue further in this pull request: https://github.com/SQL-Server-projects/TSQL-Scripts/pull/9

Imran-imtiaz48 avatar May 18 '25 07:05 Imran-imtiaz48