Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Use mapped network drive for addfile command Expand / Collapse
Author
Message
Posted Wednesday, February 20, 2013 12:50 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:05 PM
Points: 175, Visits: 449
I have a production server with volume a and b. DR server has volume a, not b. I was hoping to be able to map a network drive to a as b.

Possible?

I need to add a filegroup and file to production but the dr server (LOG SHIPPING) will not have the volume available when the command passes through log shipping.
Post #1422256
Posted Wednesday, February 20, 2013 1:05 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 11:50 AM
Points: 12,877, Visits: 31,792
the command for mapping a drive is fairly straightforward:
NET USE G: \\UNCPath\d$\ShareFolder /user:domain\username password


after that is done, i think you might also need to add the trace flag 1807 to allow the SQL instance to use network paths?


Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1422268
Posted Wednesday, February 20, 2013 1:13 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:05 PM
Points: 175, Visits: 449
I had been using "NET USE j: \\SAMESERVER\C$\SQL\SQL_Data\J /persistent:yes", even to the point of running through a scheduled task in a batch script, as the service account. The service account is not logged onto the machine at any time.

I was hoping the trace flag would work, but appears to not. Good information to note. Maybe playing with the trace flag at levels above session may give me a better start.

I had been running
USE [master]
GO

DBCC TraceON (1807)
GO

ALTER DATABASE [DATABASE] ADD FILE
( NAME = N'TESTING',
FILENAME = N'J:\TESTING_Archive.ndf' ,
SIZE = 3072000KB ,
FILEGROWTH = 10%) TO FILEGROUP [TestAnother]
GO

I had been getting the error of
Msg 5133, Level 16, State 1, Line 2
Directory lookup for the file "J:\LIFT_Data_Archive.ndf" failed with the operating system error 3(The system cannot find the path specified.).
Msg 5009, Level 16, State 8, Line 2
One or more files listed in the statement could not be found or could not be initialized.

Post #1422271
Posted Wednesday, February 20, 2013 1:24 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 11:50 AM
Points: 12,877, Visits: 31,792
matt this worked 100% for me as an example; the difference here is I used the username parameters for the net use as a user that has permissions on the network;

from there, i got an error on adding the filegroup, until i set the trace flag:

exec master.dbo.xp_cmdshell 'NET USE J: \\DEV223\c$\DataFiles /user:disney\lizaguirre NotTheRealPassword /persistent:yes'


ALTER DATABASE [SandBox] ADD FILE
( NAME = N'TESTING',
FILENAME = N'J:\TESTING_Archive.ndf' ,
SIZE = 3072KB ,
FILEGROWTH = 10%)
/*
Msg 5110, Level 16, State 2, Line 1
The file "J:\TESTING_Archive.ndf" is on a network path that is not supported for database files.
Msg 5009, Level 16, State 8, Line 1
One or more files listed in the statement could not be found or could not be initialized.
*/

DBCC TraceON (1807)

ALTER DATABASE [SandBox] ADD FILE
( NAME = N'TESTING',
FILENAME = N'J:\TESTING_Archive.ndf' ,
SIZE = 3072KB ,
FILEGROWTH = 10%)
/*
Command(s) completed successfully.
*/



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1422279
Posted Wednesday, February 20, 2013 1:34 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, March 31, 2014 3:05 PM
Points: 175, Visits: 449
AWESOME! Thanks!

I had not been using xp_cmdshell to execute the net use command. I knew I was getting hung up in permissions but just didn't know where. Well, now I guess I will just really hope that a log shipping restore session won't break and all goes smoothly (save the time of re-doing log shipping). Have been testing on testing server and it's looking clean.

EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO

exec master.dbo.xp_cmdshell 'NET USE.......

Post #1422288
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse