MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
5 Points
114 Posts
Batch to backup database
Mar 10, 2019 03:24 PM|thepast|LINK
i want simple batch to backup my database
i want name comes like this
Mm-09-03-2019
and want my batch stored in D:\ driver
How can i do that
All-Star
52971 Points
23574 Posts
Re: Batch to backup database
Mar 10, 2019 05:23 PM|mgebhard|LINK
Pretty simple. Use osql or cmdsql to build a command line .bat file. Then schedule the task to run through Windows Task scheduler or the SQL agent.
https://docs.microsoft.com/en-us/sql/tools/osql-utility?view=sql-server-2017
https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017
Simply lookup bat command for naming files and working with dates. There are tons of online resources.
Contributor
3500 Points
1300 Posts
Re: Batch to backup database
Mar 11, 2019 05:28 AM|Ackerly Xu|LINK
Hi thepast,
If you want to back up your database using ssms,you could right click the database in your ssms -> choose tasks -> choose generate scripts .
Then in the pop-up wizard, choose Choose Objects, click next , then you could choose where to export the script.
You could also specify the vision of your script (whether sqlserver2008 ,sqlserver2017...)
In the save script wizard, please click Advanced , choose script for server version , and then choose your remove server's version.
Or you could choose to backup when choosing task.
https://support.clio.com/hc/en-us/articles/360000635193-How-to-Back-Up-an-SQL-database-using-Microsoft-SQL-Server-Management-Studio-Express
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
5 Points
114 Posts
Re: Batch to backup database
Mar 11, 2019 06:48 AM|thepast|LINK
not through ssms I want it batch file to schedule it automatic
Contributor
3500 Points
1300 Posts
Re: Batch to backup database
Mar 11, 2019 07:24 AM|Ackerly Xu|LINK
Hi thepast,
I'm sorry , I misunderstood what you mean.
Just as mgebhard has said , you should use .bat and windows task schedule.
For how to use taskschedule, you could refer to
https://www.digitalcitizen.life/how-create-task-basic-task-wizard
About how to write the backup t-sql, please refer to
https://database.guide/how-to-backup-a-sql-server-database-using-t-sql/
You could also refer to the link below
https://stackoverflow.com/questions/7201061/how-to-create-jobs-in-sql-server-express-edition
Best regards,
Ackerly Xu
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.