Created
February 19, 2014 16:38
-
-
Save bmatzelle/9095820 to your computer and use it in GitHub Desktop.
Example of how to backup a table with SQL for SQL Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @dbName varchar(1000); | |
DECLARE @exportPath varchar(1000); | |
SET @exportPath = 'C:\Database_Backups'; | |
SET @dbName = 'YourDatabase'; | |
-- Backs up data in the format: "[DB_name]_YYYY.MM.DD.bak" | |
SET @exportPath = @exportPath + '\' + @dbName + '_' + | |
(SELECT CONVERT(VARCHAR(12), GETDATE(), 102)) + '.bak'; | |
BACKUP DATABASE @dbName TO DISK = @exportPath; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment