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.)

0

2 Answers 2

6

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.