Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
marjan.sayyad
Starting Member
15 Posts |
Posted - 2013-12-18 : 18:30:29
|
Hello everybody, I am trying to do this command :sqlcmd -S servername\instancename,1433 -E -d dbname -i c:\mypath\myscript.sql -o c:\mypath\myoutput.txt and inside input file I put an easy select query, and this command works on the local machine, but when I run this command from a remoe machine, all the time I get bellow error:sqlcmd: Error: Error occurred while opening or operating on file c:\mypath\myscript.sql ( Reason: The system cannot the path specified ) any help would be appreciated. ThanksMp |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-18 : 21:54:42
|
does myscript.sql existed in c:\mypath of the remote machine ?make sure myscript.sql existed in the remote machine and specify the correct path KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-19 : 03:22:09
|
quote: Originally posted by marjan.sayyad Hello everybody, I am trying to do this command :sqlcmd -S servername\instancename,1433 -E -d dbname -i c:\mypath\myscript.sql -o c:\mypath\myoutput.txt and inside input file I put an easy select query, and this command works on the local machine, but when I run this command from a remoe machine, all the time I get bellow error:sqlcmd: Error: Error occurred while opening or operating on file c:\mypath\myscript.sql ( Reason: The system cannot the path specified ) any help would be appreciated. ThanksMp
Two thingscheck if path exists within machine where script is run. If path is actually a path in your local machine then use UNC path \machinename \... or \\ipaddress\...2. Make location shared giving access to account executing sqlcmd------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
marjan.sayyad
Starting Member
15 Posts |
Posted - 2013-12-19 : 17:28:00
|
When I added ip address like you said I got the bellow error either when I run it from local server or from remote machine:sqlcmd: Error: Error occurred while opening or operating on file c:\mypath\myscript.sql ( Reason: The system cannot the path specified ) Let me explain a little mor about my problem:-I Do not have sel server on the remore machine. I just have sql server on my local server.-I put sqlcmd commant on a batch file on the c drive of local server, and batch file works when I do not add ip address in my command.- because I wanted to know the problem I did that:on the command line of the remote machine I typted:\\servername\c$ then I have full access to c drive , but when I run batch file I get this error. I do not know why??? because it works when I run the same batch file on the local server.Please give me a solution quote: Originally posted by visakh16
quote: Originally posted by marjan.sayyad Hello everybody, I am trying to do this command :sqlcmd -S servername\instancename,1433 -E -d dbname -i c:\mypath\myscript.sql -o c:\mypath\myoutput.txt and inside input file I put an easy select query, and this command works on the local machine, but when I run this command from a remoe machine, all the time I get bellow error:sqlcmd: Error: Error occurred while opening or operating on file c:\mypath\myscript.sql ( Reason: The system cannot the path specified ) any help would be appreciated. ThanksMp
Two thingscheck if path exists within machine where script is run. If path is actually a path in your local machine then use UNC path \machinename \... or \\ipaddress\...2. Make location shared giving access to account executing sqlcmd------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs
Mp |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2013-12-19 : 21:18:09
|
can you show us the exact command you used in the remote machine ? KH[spoiler]Time is always against us[/spoiler] |
|
|
marjan.sayyad
Starting Member
15 Posts |
Posted - 2013-12-20 : 11:44:16
|
sqlcmd -S servername\instancename,1433 -E -d dbname -i c:\mypath\myscript.sql -o c:\mypath\myoutput.txtthese paths exit on the server. On my pc on the command line I type: \\servername\c$ then run the same command on batch file ,and I get that errorThanks for your help!!!Mp |
|
|
|
|
|
|
|