BigGinDaHouse
BigGinDaHouse

Reputation: 1346

SQL Server BCP tool

I'm trying to IMPORT data from EXPORTED Dat file from SQL Server in this way:

bcp "SELECT FieldName FROM [BaseName].[dbo].[TableName] where xxxxxx=16" 
    queryout Message_out.dat -n -Uusername -Sservername

When I try to import dat to sql server like this

bcp basename.dbo.tablename in "path\to\datfile.dat" -c -T 

I get error:

Error = [Microsoft][SQL Server Native Client 10.0]Unexpected EOF encountered in BCP data-file

regards, Grigor.

Upvotes: 2

Views: 2163

Answers (1)

bubbassauro
bubbassauro

Reputation: 4279

Try to explicitly indicate the field and row terminators for your file, for example, if your file is comma delimited and each row is in a new line:

bcp basename.dbo.tablename in "path\to\datfile.dat" -c -T -r\n -t,

And if if there are any other peculiarities in the format of your file, use the options to help bcp understand your file format using the options. A detailed documentation is available at msdn.

I see this question is old, but maybe it will help someone in the future...

Upvotes: 1

Related Questions