August 6, 2011 at 2:44 am
Hi all
I am facing hard time in configuring the BCP command to to import data from txt file (Pipe as Field terminator)into SQL Table.
As the TAB is the default field terminator for BCP. And My source file is | (Pipe delimited file)
I tried this
BCP Work.dbo.Customer IN "\\MyMechine\Shared\Cust.txt" -T -S "SQLSERVER" -t|
Am I missing some thing here.
Please help me.
August 6, 2011 at 2:38 pm
anand_vanam (8/6/2011)
Hi allI am facing hard time in configuring the BCP command to to import data from txt file (Pipe as Field terminator)into SQL Table.
As the TAB is the default field terminator for BCP. And My source file is | (Pipe delimited file)
I tried this
BCP Work.dbo.Customer IN "\\MyMechine\Shared\Cust.txt" -T -S "SQLSERVER" -t|
Am I missing some thing here.
Please help me.
Are you getting an error or what? You haven't told us what the problem actually is. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
August 8, 2011 at 11:01 am
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]Unexpected EOF encountered in
BCP data-file
0 rows copied.
I got this Error.
I even added the "format file".
I have 3 columns in the Table. No Identtity Column. and No PK's
CREATE TABLE dbo.Cust
(Sno INT,
Name Varchar(20),
Location Varchar(30)
)
And the .txt file has 3 columns... with Pipe delimited.
Ex:
1|Cust1|Newyook
2|John|Washington
100|Alan|Seattle
August 8, 2011 at 12:02 pm
my bcp OUt exampel shows the delimiter between dbl quotes, and not the sole char after the -t.
try that...
also check your row terminator; if it's not CrLf, you might need to change /add the -r command for the row terminator:
-r"\r"
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT * FROM ##PIPE_REPORT " queryout C:\Data\Objects.txt -t"|" -c -T '
Lowell
August 8, 2011 at 9:33 pm
Thanks that helped alot.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply