Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

File paths in SQL Server

Jun 18 2012 12:00AM by Madhivanan   

Often you see people complaining that although the file exists in the directory, the code throws an error Operating system error 2(The system cannot find the file specified.). Ok. The following need the file path to be specified in the code

1 Backup/Restore a database
2 Attach a database file
3 Bulk Insert
4 BCP to a file
5 Accessing files (.txt,.csv,etc) via OPENROWSET like Export to Excel with column names
etc

You need to be awared that the file path specified in your code is, by default, expected to be available in SERVER's physical directory and not in your LOCAL system's directory. Most of the newbies forget this and have the files in their local system and expect SQL Server to access the files. If you have files in your local system do either of these

1 Copy the files to SERVER's directory and run the code
2 Have files in your LOCAL system, let the SERVER has enough permission to access files from your local system and use UNC Path

Here is an example of how to let the SERVER use files from local system using UNC path. If you have backup file named test.bak in D directory of your local system named test, use the following code to restore it without copying it the Server's directory

restore database mydb from disk='\\test\D$\test.bak'

So be aware of this and next time when your code shows the non-availability of files, just think about the above.

Tags: #sql,#sqlserver,#tsql


Madhivanan
3 · 40% · 12947
6
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

7  Comments  

  • To the best of my knowledge, C$ or D$ indicate that these are administrative shares and access is not available to anyone except the administrator of the workstation/server, which means that in most cases, the SQL Server service would not be able to access it. Is that not a correct understanding?

    commented on Jun 18 2012 1:40AM
    Nakul Vachhrajani
    4 · 36% · 11645
  • I agree with Nakul - C$ / D$ indicate that there are administrative share and only admin users can use it.

    commented on Jun 18 2012 6:49AM
    Hardik Doshi
    20 · 9% · 2864
  • Well. I always used to use $ :)

    commented on Jun 19 2012 12:53AM
    Madhivanan
    3 · 40% · 12947
  • I have faced issue some time like parent folder is in readonly mode then also we got permission denied error. after unchecking readonly it works fine.

    commented on Jun 20 2012 12:06PM
    Jeetendra
    145 · 1% · 342
  • You can create a public share on your computer on the fly like this in DOS:

    net share backup=C:\MyBackups

    You can then connect with sqlcmd and do:

    backup database MyDatabase to disk='\MyComputer\backup\MyDatabase.bak' with stats=1

    Sometimes instead of MyComputer I have to put my IP address.

    At the end you do:

    net share backup /d

    No special privileges needed for this.

    commented on Jun 27 2012 1:59AM
    dishdy
    16 · 10% · 3269
  • Thats a good technique dishdy. Thanks

    commented on Jun 27 2012 2:04AM
    Madhivanan
    3 · 40% · 12947
  • Good one. Thanks for sharing dishdy

    commented on Jun 27 2012 2:11AM
    Hardik Doshi
    20 · 9% · 2864

Your Comment


Sign Up or Login to post a comment.

"File paths in SQL Server" rated 5 out of 5 by 6 readers
File paths in SQL Server , 5.0 out of 5 based on 6 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]