SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Use mapped network drive for addfile command


Use mapped network drive for addfile command

Author
Message
matt.newman
matt.newman
SSC Eights!
SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)

Group: General Forum Members
Points: 826 Visits: 473
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.
Lowell
Lowell
SSC Guru
SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)

Group: General Forum Members
Points: 70066 Visits: 40923
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
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
matt.newman
matt.newman
SSC Eights!
SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)

Group: General Forum Members
Points: 826 Visits: 473
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.


Lowell
Lowell
SSC Guru
SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)SSC Guru (70K reputation)

Group: General Forum Members
Points: 70066 Visits: 40923
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
--help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!
matt.newman
matt.newman
SSC Eights!
SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)SSC Eights! (826 reputation)

Group: General Forum Members
Points: 826 Visits: 473
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.......


Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search