Solved

sql to access file in different server

Posted on 2014-09-25
6
127 Views
Last Modified: 2014-10-06
Hi,

I have a test file in server A and my DB server is in server B.
Now I want to write query in SSMS from Server B and that query should access the file from server A and parse it to store the data in DB.

I am not sure how to establish the connection to server B and get that file.
I am trying to write a stored procedure for this.
No I should not copy that file.

So any suggestions how to get that file from server B to DB server A.

Thanks,
0
Comment
Question by:shragi
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 3

Assisted Solution

by:Matthew Borrusso
Matthew Borrusso earned 250 total points
ID: 40344873
You need to write the query to import, say CSV from a network location.

if this is batch-able, you may want to do something like xcopy \\server1\data.csv d:\temp or whatever.

schedule this transfer to occur in conjunction with your export. Say 6 am export data from whatever to this CSV, 7am perform the batch to xcopy the data to the server. then 8 pm schedule your query to import the csv accordingly..

Times would be your gig.. Granted, this is not the cleanest way to do it, but if you have to import/export, this might just be an easy way if you cannot just create a connector and directly transfer the data table to table.
0
 
LVL 3

Expert Comment

by:Matthew Borrusso
ID: 40344877
Again, I just want to say, I know its not clean.. but it should work given limited options.
0
 

Author Comment

by:shragi
ID: 40344949
does this command removes the file from original server B
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 3

Expert Comment

by:Matthew Borrusso
ID: 40344997
you can add a delete command to be run later. say 10am, or just set the commands to constantly overwrite the file names.
your call..

it just depends on how you want to do this.
0
 
LVL 11

Accepted Solution

by:
John_Vidmar earned 250 total points
ID: 40345004
Use SQL Server Integration Services (SSIS) to read the file in it's original location, perform data transformations (if required), and store the data in SQL Server.  SSIS can also do other non-database tasks, like move/copy/delete/rename files.
0
 
LVL 49

Expert Comment

by:Vitor Montalvão
ID: 40345490
If the idea it's to import data from a file to a table SSMS already provide this functionality.
Just right-click over the database name, choose Tasks / Import data... and follow the wizard.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question