Results 1 to 11 of 11
  1. #1
    Join Date
    Jun 2008
    Location
    India
    Posts
    96

    Unanswered: BULK INSERT in Sybase

    Does support BULK INSERT ?

    Actually,I have done the below one to load.CSV file into the table.

    But i failed to upload.
    ------------------------------------------------------------------
    I have written the below code.

    create table bcpt
    (
    eno int,
    ename varchar(255)
    )

    I have to upload the data from .CSV file.

    Assume the .CSV file format is

    1 karthik
    2 keyan

    I wrote the below sqlcode.

    create proc bcp_test
    as
    begin
    exec master..xp_cmdshell "bcp acs..bcpt in "C:\temp\Book1.csv -c -Upf -Ppf1 -Sdev"
    end

    While executing the above procedure, i got the below error message.

    -----------------------------------------
    CTLIB Message: - L6/O8/S5/N3/5/0:
    ct_connect(): directory service layer: internal directory control layer error: Requested server name not found.
    Establishing connection failed.
    -----------------------------------------

    Inputs are welcome !

  2. #2
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    As the error says, it can't find the servername 'dev' you specified with the -S flag. I assume the bcp-command is executed on the server where ASE runs, so 'dev' should be in the sql.ini on that server.
    Also, the csv should be located on the server, not on your client.
    I'm not crazy, I'm an aeroplane!

  3. #3
    Join Date
    Jun 2008
    Location
    India
    Posts
    96
    SQLADVANTAGE is connected with 'dev' server only.

    ok...

    is there any option to set -S option to see my local .INI file ?

  4. #4
    Join Date
    Jun 2008
    Location
    India
    Posts
    96
    or can i use -I option.

    like

    -I c:\ProgramFiles\Sybase\bin\SQL.INI

    can i use like this ?

  5. #5
    Join Date
    Jun 2008
    Location
    India
    Posts
    96
    I have modified my code as below.

    Drop proc bcp_test
    go
    create proc bcp_test
    as
    begin

    Declare @sql varchar(255)
    Declare @Path varchar(255),@ini varchar(255),@errortext varchar(255)
    Select @Path = 'C:\Program Files\Sybase\OCS-12_5\bin\t.bat'
    Select @ini = 'C:\Program Files\Sybase\ini\SQL.ini'

    SELECT @sql = "bcp acs..bcpt in " +''''+@Path +''''+ " -c -Upf -Ppf1 -I" +''''+@ini +''''+" -Sdev"
    print @sql
    exec master..xp_cmdshell @sql

    end

    But still,I am facing the same error message.

  6. #6
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    All paths you enter in SQL-advantage are handled as if the were on the server, not your client/pc.
    exec master..xp_cmdshell "bcp acs..bcpt in "C:\temp\Book1.csv -c -Upf -Ppf1 -Sdev" can work, but you have to be sure that dev exists in the sql.ini-file on the server. Can't you look it up on the server?

    By the way, what are you trying to accomplish? A way to bcp-in a csv regularly? Or just once?
    I'm not crazy, I'm an aeroplane!

  7. #7
    Join Date
    Jun 2008
    Location
    India
    Posts
    96
    not once.
    May be daily,twice a day,weekly basis or once for 15 days. All depends on the hands of Endusers.

  8. #8
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    That won't be a problem, just figure out what the name is in sql.ini on the server, use that for the -S -flag. You can keep the C:\temp\Book1.csv, as long as you place the csv as Book1.csv on the server in C:\temp, every time you want to run the script.

    Also, watch out for the quotes:
    exec master..xp_cmdshell "bcp acs..bcpt in "C:\temp\Book1.csv -c -Upf -Ppf1 -Sdev" won't work because of the extra " in fromt of C:\. Delete that quote and it will work.
    I'm not crazy, I'm an aeroplane!

  9. #9
    Join Date
    Jun 2008
    Location
    India
    Posts
    96
    if sybase provide BULK INSERT option, it would be easy for us. mmmm.....

  10. #10
    Join Date
    Sep 2008
    Posts
    40

    reg bulk insert

    hi,

    does the server that you want to insert data into is configured as the same name that you have given in -S parameter.
    From the error it means it is unable to establish the connection. just check with dsedit if the server name is configured and also check if username and password are correct

  11. #11
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Quote Originally Posted by karthi_syb
    if sybase provide BULK INSERT option, it would be easy for us. mmmm.....
    The bcp-command you're trying to execute IS bulk Insert. You just have to make sure that the servernames are correct.
    I'm not crazy, I'm an aeroplane!

Posting Permissions

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