Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create Non-XML Format File for Bulk Insert - Error: Could not open connection to Sql Server 1

Status
Not open for further replies.

BxWill

MIS
Mar 30, 2009
367
0
16
US
Encounter an error upon attempting to create a format file.

Context: Have a very large comma delimited file that has over 1.3 million records. Upon opening the file with EmEditor, I delete the
comment line that is on the very last record.

Due to a comma within one of the fields, it appears best that I use a format file to enable a bulk insert of the entire file into the associated yearly tables within the Sql Server 2012 database. For exammple, EquipSales_2013, EquipSales_2014, and so on.

Upon copy pasting the following line at the command prompt, I encounter an error, as displayed below as well.

[Bold]
C:\Users\WillCa>bcp Equipment.dbo.EquipSales_2013 format nul -c -f C:\EquipData\EquipSales_2013.fmt -t, -T
[/Bold]

Code:
SQLState = 08001, NativeError = 2
Error = [Microsoft][ODBC Driver 11 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [2].

SQLState = 08001, NativeError = 2
 
Error = [Microsoft][ODBC Driver 11 for SQL Server]A network-related or instance-
specific error has occurred while establishing a connection to SQL Server. 

Server is not found or not accessible. Check if instance name is correct and if SQL S
erver is configured to allow remote connections. 

For more information see SQL Server Books Online.
SQLState = S1T00, NativeError = 0
Error = [Microsoft][ODBC Driver 11 for SQL Server]Login timeout expired


I did verify the following but still not able to create the format file.


Step 1: Check to ensure tha SQL Services are running Yes.
There appears to be the instance for Sql Server 2012 and also for Sql Express.

Step 2: Check that I am indeed using the correct Sql Server instance name - INSTANCE2 Yes.

Step 3: checked that I can find the SQL Server using sqlcmd -L at command prompt. Yes.

Step 4: Checked that allow remote connections to this server is enabled. Yes.

Any insight as to how I resolve the error?
 
there is no servername to connect to on the command line you supplied
bcp Equipment.dbo.EquipSales_2013 format nul -c -f C:\EquipData\EquipSales_2013.fmt -t, -T

you need to add the option -S servername\instance (\instance if named instance used)

otherwise it will try to connect to a default instance on the computer where you execute the bcp command


Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top