How To: Create Dynamic File System Directory in TSQL
I have created a Backup Script to backup all the databases in our SQL Server 2005. I want to keep old backups for sometime for some reason; so I want to create subdirectory with the run date as the name of the folder to separate the set of backups by date.
I need to use DOS Command from within my TSQL Code to create the subdirectory. This feature is turned off by default. I am making sure that I am turning this off after I run the script:
Then here’s how I execute DOS Command from within my TSQL:
For security reason, I want to make sure that I turn my xp_cmdshell off. So at the very end of my script:
News-Worthy: Linked DBA Blog Featured in ITSpecialist.com: http://www.itspecialist.com/Developer/Microsoft/SQL/tabid/548/articleType/ArticleView/articleId/41/Linked-DBA-Group.aspx#Comments