December 6, 2011 at 10:42 am
I am running SQL Server 2008 and I wish to backup a database to a server that is on the network but not a member of the domain. A username and password must be provided to access the disk. In the example below, can I provide the necessary credentials? If so, what is the syntax?
BACKUP DATABASE AdventureWorks2008R2
TO DISK = '\\evy14\itdept\SQL_Backups\test.bak'
WITH FORMAT;
GO
December 6, 2011 at 11:13 am
yes it's possible because of the way the NET USE command can allow you to map a drive with someones credentials
exec master.dbo.xp_cmshell 'NET USE G: \\UNCPath\d$ /user:domain\user password'
something like this would work for what you are asking:
exec master.dbo.xp_cmshell 'NET USE Z: \\evy14\itdept\SQL_Backups\ /user:mydomain\lowell NotTheRealPassword'
BACKUP DATABASE AdventureWorks2008R2
TO DISK = 'Z:test.bak'
WITH FORMAT;
EXEC master.dbo.xp_cmdshell 'NET USE Z: /DELETE'
Lowell
December 6, 2011 at 12:27 pm
Works great. Thanks for the help.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply