Wednesday 15 February 2012

DOS Command to take back up in SQL server


This is a simple dos command to take backup


echo off
cls


set /p DBNAME=Enter database name:
set BACKUP=c:\backup\%DBNAME%.bak
set SQLSERVERNAME=kiran


echo.


sqlcmd -E -S %SQLSERVERNAME% -d master -Q "BACKUP DATABASE [%DBNAME%] TO DISK = N'%BACKUP%'"


echo.
pause



Steps

  • Copy the entire content and paste in a notepad
  • Change the sever name in my case it is kiran
  • Create a folder in c or d to take a backup. In my case my folder name is backup which is created in c drive


No comments:

Post a Comment

Please Leave Your Comment here

You Might also like this

Related Posts Plugin for WordPress, Blogger...