user2184057
user2184057

Reputation: 964

SQL Server Bulk Insert Format FIle could not be opened

I'm trying to use Bulk Insert to insert some data into my database on local computer. I am using a SQL Server Express database and executing query using Microsoft SQL Server Management Studio. When I try to execute a query I get this error.

Cannot bulk load because the file "‪D:\Countries.xml" could not be opened. Operating system error code 123(The filename, directory name, or volume label syntax is incorrect.).

I have been moving this file over my HDD by everywhere and still got the same error. To be honest I have no idea what is going on. Any tips?

BULK INSERT Research.dbo.Countries
FROM 'C:\Users\someuser\Desktop\Localization DB\countryInfo.txt' WITH 
    (
        FORMATFILE='‪D:\Countries.xml',
        FIRSTROW=2,
        CHECK_CONSTRAINTS
    );
GO

Upvotes: 1

Views: 5471

Answers (3)

shop350
shop350

Reputation: 208

when you copy a path for example from properties of file

copy path

copied text have some extra thrash bytes, you need to view pasted text as ANSI and will be revealed

pasted text as utf-8

pasted text as ansi

Upvotes: 5

Brian Nordberg
Brian Nordberg

Reputation: 86

Are you 100% sure you are connecting to you locally installed SQL Server - not a networked one? That's my favorite thing to do, rdp into a machine, or on a VM, and forget where I am physically connected. If you copy and paste from Word, sometimes it puts in the wrong type of ' back that out and replace.

Upvotes: 3

user2184057
user2184057

Reputation: 964

I have no idea why but the problem was with ' mark being copied. When i deleted it and put it from keyboard it started working.

Upvotes: 2

Related Questions