December 14, 2017 at 1:51 am
Hi Guys,
I am creating back ups of my database using code:
USE QlikView;
GO
BACKUP DATABASE QlikView
TO DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL12.SERVERTEST\MSSQL\Backup\QlikView.Bak'
WITH FORMAT,
MEDIANAME = 'C_SQLServerBackups',
NAME = 'Full Backup of QlikView';
GO
It is ok but question is can i create these back ups only on the last day of every month?
I can do it in VBscript and set up task scheduler on server but maybe there is a simple way to create back up in MS SQL SERVER EXPRESS using T-SQL?
Jacek
December 14, 2017 at 1:52 am
I think that i will have to use VBscript anyway because i have to run scripts outside from SQL Server express because i do not have Job Assistant here...
Jacek
December 14, 2017 at 2:14 am
You could use the Windows task scheduler instead. By the way, don't back up to the C drive. Make sure backups go to a different disk from the operating system and database files, and thereafter off the server all together as quickly as possible.
John
December 14, 2017 at 2:29 am
thank you John!
Ok this is better idea to have backups on different drive then C drive.
Question about tash scheduler in Windows. I can set up the task here but some code should run MS SQL Server Query.
What can you recommendt?
Jacek
December 14, 2017 at 2:50 am
jaryszek - Thursday, December 14, 2017 2:29 AMQuestion about tash scheduler in Windows. I can set up the task here but some code should run MS SQL Server Query.
What can you recommendt?
Jacek
Have a look at this. It's a command-line utility for running SQL queries. It'll be available on your server by default.
John
December 14, 2017 at 3:05 am
Thank you John,
I will test it !
Jacek
December 18, 2017 at 12:44 pm
another way of doing backup for all databases, I use this for SQL express backup via sqlcmd/task schedular, BTW you can use SQL agent from standard/developer/enterprise edition to take backup of SQL express instance provided appropriate ports are open and SQL agent have access to express edition/server.
declare @cmd varchar(5000)
select @cmd ='if ''tempdb'' <> cast(''?'' as nvarchar) backup database [?] to disk =''x:\sql_backup\?\?_2017_06_15.bak'''
PRINT @cmd
exec sp_msforeachdb @cmd
December 18, 2017 at 1:09 pm
My concern is only backing up the database once a month. If you don't mind losing almost one months data due to a failure just before your monthly backup, you really should backup the database more frequently.
December 18, 2017 at 11:42 pm
Hi Guys,
thank you!
I do not have SQL server Agent and standard SQL edition.
This code:declare @cmd varchar(5000)
select @cmd ='if ''tempdb'' <> cast(''?'' as nvarchar) backup database [?] to disk =''x:\sql_backup\?\?_2017_06_15.bak'''
PRINT @cmd
exec sp_msforeachdb @cmd
is for SQL Server Agent or cmd task ?
Best Wishes,
Jacek
December 19, 2017 at 12:27 am
That's T-SQL, so no, it won't run in command line.
You can run it via the util that John mentioned.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 19, 2017 at 12:41 am
Thank you Guys!
The best method and the simplest for me is creating VBscript and run it via tash scheduler.
Best wishes,
Jacek
December 19, 2017 at 1:19 am
Simpler than calling SQLCMD and passing it T-SQL? Ok.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
December 19, 2017 at 1:56 am
Yes,
I can create query in MS SQL Server, save it and simple run via VBscript code.
So i am using T-SQL within Query Designer in MS SQL Server.
Best Wishes,
Jacek Antek
Viewing 13 posts - 1 through 12 (of 12 total)
You must be logged in to reply to this topic. Login to reply