Showing posts with label filename. Show all posts
Showing posts with label filename. Show all posts

Thursday, March 22, 2012

BACKUP SERVICE MASTER KEY TO FILE

Hello,
I would to create a backup file dynamically (the filename will contain
the hostname of the DB).
any idea how can I use a variable for that?
(a variable is easy to use for a regular database backup, but not for
a master key).
I wrote on the comment the error I get.
thanks, Yaniv
use master;
declare @.tmpStr varchar(200)
set @.tmpStr = 'c:\temp\DB_service_2.key'
-- working
BACKUP SERVICE MASTER KEY TO FILE = 'c:\temp\DB_service.key'
ENCRYPTION BY
PASSWORD = 't1t1t1t1t1'
-- error: Incorrect syntax near '@.tmpStr'
BACKUP SERVICE MASTER KEY TO FILE = @.tmpStr ENCRYPTION BY PASSWORD =
't1t1t1t1t1'
goYou can use dynamic SQL. Built the BACKUP command in a TSQL varchar variable
, then execute it:
EXEC(@.sql)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<yaniv.harpaz@.gmail.com> wrote in message
news:1170238336.716966.152710@.p10g2000cwp.googlegroups.com...
> Hello,
> I would to create a backup file dynamically (the filename will contain
> the hostname of the DB).
> any idea how can I use a variable for that?
> (a variable is easy to use for a regular database backup, but not for
> a master key).
> I wrote on the comment the error I get.
> thanks, Yaniv
> use master;
> declare @.tmpStr varchar(200)
> set @.tmpStr = 'c:\temp\DB_service_2.key'
> -- working
> BACKUP SERVICE MASTER KEY TO FILE = 'c:\temp\DB_service.key'
> ENCRYPTION BY
> PASSWORD = 't1t1t1t1t1'
> -- error: Incorrect syntax near '@.tmpStr'
> BACKUP SERVICE MASTER KEY TO FILE = @.tmpStr ENCRYPTION BY PASSWORD =
> 't1t1t1t1t1'
> go
>

BACKUP SERVICE MASTER KEY TO FILE

Hello,
I would to create a backup file dynamically (the filename will contain
the hostname of the DB).
any idea how can I use a variable for that?
(a variable is easy to use for a regular database backup, but not for
a master key).
I wrote on the comment the error I get.
thanks, Yaniv
use master;
declare @.tmpStr varchar(200)
set @.tmpStr = 'c:\temp\DB_service_2.key'
-- working
BACKUP SERVICE MASTER KEY TO FILE = 'c:\temp\DB_service.key'
ENCRYPTION BY
PASSWORD = 't1t1t1t1t1'
-- error: Incorrect syntax near '@.tmpStr'
BACKUP SERVICE MASTER KEY TO FILE = @.tmpStr ENCRYPTION BY PASSWORD = 't1t1t1t1t1'
goYou can use dynamic SQL. Built the BACKUP command in a TSQL varchar variable, then execute it:
EXEC(@.sql)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
<yaniv.harpaz@.gmail.com> wrote in message
news:1170238336.716966.152710@.p10g2000cwp.googlegroups.com...
> Hello,
> I would to create a backup file dynamically (the filename will contain
> the hostname of the DB).
> any idea how can I use a variable for that?
> (a variable is easy to use for a regular database backup, but not for
> a master key).
> I wrote on the comment the error I get.
> thanks, Yaniv
> use master;
> declare @.tmpStr varchar(200)
> set @.tmpStr = 'c:\temp\DB_service_2.key'
> -- working
> BACKUP SERVICE MASTER KEY TO FILE = 'c:\temp\DB_service.key'
> ENCRYPTION BY
> PASSWORD = 't1t1t1t1t1'
> -- error: Incorrect syntax near '@.tmpStr'
> BACKUP SERVICE MASTER KEY TO FILE = @.tmpStr ENCRYPTION BY PASSWORD => 't1t1t1t1t1'
> go
>

Friday, February 24, 2012

BackUp my DataBase on MSSQLServer Express

Hello my friends!

I have designed a database on a SQLServer Express. When I am going to backup it, I provide a filename like as "c:/test.bak" but when executing I recieve a message that SQLServer cannot open the backup device with the name above.

hi,

please verify (via SQL Server Configuration Manager->SQL Server 2005 services->YourSQLInstance->Properties) that the account running the service has enought permissions on the target path...

by default SQLExpress installs setting that account as Network Service and this account does not have that permissions (read-write) outside the instance path.. you can modify the NTFS permissions of the path as well allowing the running account as required..

regards