5

I currently have a machine A with SQL Server Management Studio (SSMS), and a data file on it.

A connects to machine B's SQL Server database. I have no control of machine B.

The problem is:

I can't transfer data using neither DB restore, DB attach, nor bulk import. Because for any query like

BULK INSERT [MY_TABLE_NAME] 
FROM 'F:\Data\MY_TABLE_NAME.txt' WITH (
FIRSTROW=2,
FORMATFILE='F:\Data\MY_TABLE_NAME.txt.fmt')
RESTORE DATABASE MY_TABLE_NAME
FROM DISK = 'F:\Data\MY_TABLE_NAME.bak'
WITH REPLACE

SQL Server Management Studio will try to open the file in B machine, not my machine A. (I can't transfer the file to machine B.)

Is there a way to open the local file in this situation? (Technically, I can use a Python script to insert table by table, row by row, but that would be way too inconvenient.)

asked Jan 2, 2021 at 16:36
0

2 Answers 2

6

Use BCP, or the SQL Server Import and Export Wizard. Both will read from local files.

answered Jan 2, 2021 at 17:02
0
0

If you want to import a data file, use BCP or the import wizard (as David Browne already wrote).

If you need to restore a backup file, you can:

a) put the backup file on a network drive (accessible from the server) or create a file share on your computer (if the server can access your computer)

b) restore the backup file from an Azure storage container (if the server can access the internet), see https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/restoring-from-backups-stored-in-microsoft-azure

answered Jan 2, 2021 at 18:59

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.