Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    101

    Unanswered: bcp/bulk insert question

    I have a table with 3 columns
    name1 name2 number

    csv file has the data like the following

    Dave Chris,"Ken, David", 1234

    --- BCP Command

    declare @sql varchar (4000)

    set @sql='exec master..xp_cmdshell ''bcp "test.dbo.testdata" in "c:\test.csv" -T -c -q -t,'''
    exec (@sql)

    Getting this error
    SQLState=S1000, NativeError=0
    Error=[Microsoft][SQL Native Client] Unable to open BCP host data-file Null

    Any feedback is greatly appreciated !

  2. #2
    Join Date
    Aug 2004
    Location
    Dallas, Texas
    Posts
    831
    Quote Originally Posted by sskris View Post
    I have a table with 3 columns
    name1 name2 number

    csv file has the data like the following

    Dave Chris,"Ken, David", 1234

    --- BCP Command

    declare @sql varchar (4000)

    set @sql='exec master..xp_cmdshell ''bcp "test.dbo.testdata" in "c:\test.csv" -T -c -q -t,'''
    exec (@sql)

    Getting this error
    SQLState=S1000, NativeError=0
    Error=[Microsoft][SQL Native Client] Unable to open BCP host data-file Null

    Any feedback is greatly appreciated !
    This is most likely because you are executing the query in SSMS and the file should be on server c:\ and not on local machine. Or use the fully qualified domain name: "\\server\share$\test.csv"

    I got this message when the file is on my server c:\

    NULL
    Starting copy...
    NULL
    1 rows copied.
    Network packet size (bytes): 4096
    Clock Time (ms.) Total : 16 Average : (62.50 rows per sec.)
    NULL
    Last edited by corncrowe; 01-20-11 at 06:09.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •