0

I have a ";" separated file to be imported in SQL Server. I am using bcp. I get no error but a display of bcp arguments. No data is imported. here is my code. any advise?

Create table #T1
(
    [Tracking Number] VARCHAR(200),
    [Reference Number(s)] VARCHAR(MAX),
    [Status] VARCHAR(50),
    [Manifest Date] DATETIME,
    [Ship To Name] VARCHAR(250),
    [Ship To City] VARCHAR(100),
    [Ship To State/Province] VARCHAR(100),
    [Ship To Country] VARCHAR(5),
    [Service] VARCHAR(100),
    [Scheduled Delivery] DATETIME,
    [Images] VARCHAR(100),
)

delete from [#T1]
declare @str varchar(1000)
set @str='bcp ' + '[UDF_Carrier Cost report].dbo.[#T1] in  C:\Bulk\UPS_Track_Trace.txt -c -t; -r\n -T -S ' + @@SERVERNAME
EXECUTE master.dbo.xp_cmdshell @str
select * from [#T1]
  • Is `;` breaking the command line? Try `^;` – James Z Mar 25 '16 at 08:15
  • Also, you won't be able to load data into a temp table, you need to have a normal table or a global temp. table (##T1) – James Z Mar 25 '16 at 08:17
  • Hi JamesZ. Thanks for the comment. I changed [#T1] to [T1] and [##T1] and replaced ";" by "^;" and latter used "," instead of ";" but still not working. :( –  Mar 25 '16 at 08:30
  • Try with `echo` to see that the command line doesn't get broken -- and of course try bcp outside the database first to get the command line correct. – James Z Mar 25 '16 at 14:12

0 Answers0