I am trying to import the data in a csv file into my data using the code
below, and I am getting errors.
bcp myDB.dbo.my_Table in c:\File_2009.csv -T -c
The errors are:
SQLState = 08001, NativeError = 2
Error = [Microsoft][SQL Native Client ] Named Pipes Provider: Could not open
a connection to SQL Server [2].
SQLState = 08001, NativeError = 2
Error = [Microsoft][SQL Native Client ] An error has occurred while
establishing a connection to the server. When connecting to SQL Server 2005,
this failure may be caused by the fact that uder the default settings SQL
Server does not allow remote connections.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][SQL Native Client ]Login timeout expired
I installed SQL Server in C drive. Does anyone know what causes the errors?
Thanks.
Is your SQL Server instance a Named Instance or a Default Instance? If it's
a Default Instance then ensure that its services are up and running.
Otherwise, then add -S switch to your command and specify Instance Name with
Server Name.
--
Ekrem Önsoy
"Accesshelp" <Acces...@discussions.microsoft.com>, iletisinde şunu yazdı,
news:2CDD74BC-C12F-4CBA...@microsoft.com...
Thanks for the information. I changed my code as you instructed below, and
I got a different error this time.
bcp myDB.dbo.my_Table in c:\File_2009.csv -T -c -S SERVERNAME\NAMEDINSTANCE
This time the error is:
Starting copy...
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Native Client ]Unexpected EOF encountered in BCP
data-file
0 rows copied.
Network packet size <bytes>: 4096
Clock Time <ms.> Total: 1
It looks like the error is indicating on file being imported and something
about end-of-file (EOF). Unfortunately, I don't know how to fix it.
Please help. Thanks.
To specify comma as the delimiter, you need to add:
-t,
to the command-line.
However, if your file includes quote delimiter as well, the quotes
will be imported if you only specify comma as delimiter. To import a
CSV file with quotes in it, you will need to use a format file.
But you can only do that if the quoting is consistent. If data is
quoted only sometimes, you are best off importing with only comma as
delimiter into a staging table, and then remove the quotes from SQL.
--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Thanks for the information. I got it figured out. Just like you said, I
used -t, and since csv, I used , after -t.
Below is the code that I changed to:
bcp myDB.dbo.my_Table in c:\File_2009.csv -c -t , -T -S
SERVERNAME\NAMEDINSTANCE
If you would, please help me with another problem. I just posted under "How
to manage the transaction log".
Thanks.