I tried to read the contents of single xml file in the local machine using bulk insert.
SELECT * FROM OPENROWSET ( BULK \'\'\'+ @FILENAME+\'\'\' , SINGLE_CLOB )
The issue here seems to be about file shares, not about SQL Server.
First, a drive mapping is per-user, so using drive letters causes problems when working with SQL Server because the SQL Server service account doesn't have any drive letters mapped. For that reason it's best to completely avoid drive letters and simply use UNC paths.
Next, the form of a share is \\ServerName\Share
. It looks like the file you're trying to access is in the root of the D: drive, so the correct path would be \\172.16.11.52\D$\TechnicalLoss_EnergyAccounting_10.10.2012.12.19.PM.XML
. But, note that D$
is a default admin share and only administrators can use it. Since the SQL Server service account hopefully does not have admin rights, you shouldn't be using it anyway, and storing files in the root of any drive (especially C:
) is usually a bad practice.
Finally, even if you have a share, the account you use to access the share needs to have permissions both on the share and on the filesystem. This is one benefit to running SQL Server using a domain account.
In summary, what you probably need to do is this:
D:\XMLFiles
(or whatever you like)\\172.16.11.52\XMLFiles
SELECT * FROM OPENROWSET ( BULK '\\172.16.11.52\XMLFiles\TechnicalLoss_EnergyAccounting_10.10.2012.12.19.PM.XML' , SINGLE_CLOB ) AS xmlData