Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2007
    Posts
    3

    Unanswered: Sybase Bcp Problem

    HI all

    I am facing a problem while taking bcp in sybase.

    for taking bcp out from tables we are using

    bcp database..tablename out tablename.txt -c -t , -r \\r Uusername Ppassword -Sdatabasename

    for taking BCP in from tables we are using

    bcp database..tablename in tablename.txt -c -t , -r \\r -J -Uusername -Ppassword -Sdatabasename

    But what problem i am facing here is if do BCP in two times the data is copied two times in the particular table which causes problem.is there any solution for this.

    And moreover am i going correct about BCP.is the commands i give is correct???

  2. #2
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    The -S parameter requires the servername, not the databasename.
    -r is the row-terminator, so your command only works of you have <space>\\r as an rowterminator in your bcpfiles.

    Before you bcp into a table, you should truncate the table to avoid double records. Why are you using bcp to extract/insert data from tables? For regular backup-purposes you can use dump database.
    I'm not crazy, I'm an aeroplane!

  3. #3
    Join Date
    Jul 2007
    Posts
    3
    Hi Martijnvs

    Thanks for ur Comments.It was really Useful for me.I have one more issue.

    I am having a table which has identity column.If i try to do BCP in that table

    the identity filed (say for Example Employee_id) gets filled up with some huge

    value something like 50000000002 the actual value should be 1.But in all child

    tables where (the employee id) it has foreign key relation the value 1 gets

    populated correctly.

    Can you provide any solution for this

    Regards
    Naga

  4. #4
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    Quote Originally Posted by jayanaga2000
    Hi Martijnvs

    Thanks for ur Comments.It was really Useful for me.I have one more issue.
    I am having a table which has identity column.If i try to do BCP in that table
    the identity filed (say for Example Employee_id) gets filled up with some huge
    value something like 50000000002 the actual value should be 1.But in all child
    tables where (the employee id) it has foreign key relation the value 1 gets
    populated correctly.
    Can you provide any solution for this

    Regards
    Naga
    The bcp-command has a special flag for that: -E. If you include that in your bcp-command, the values in the input-file wil be used instead of filling the column with new identityvalues.

    To avoid huge gaps in identity-columns, you can use the "identity burning set factor" configuration-option. Default value is 5000, but you can use a lower value to spend less numbers at once. The option "identity burning set factor" can be usefull too.

    For more information, see the online manual: [url=http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sag/@Generic__BookTextView/17289;pt=17289/*;lang=nl#X]Link[/url
    I'm not crazy, I'm an aeroplane!

  5. #5
    Join Date
    Jul 2007
    Posts
    3
    I have one more issue while trying to do BCP in in one of my tables i am getting an error saying

    cs_convert: cslib user api layer: common library error: The conversion/operation was stopped due to a syntax error in the source field.
    CSLIB Message: - L0/O0/S0/N24/1/0:

    What is the cause of that and how to solve that.

    Thanks again.

  6. #6
    Join Date
    Jan 2004
    Posts
    545
    Provided Answers: 4
    That message can be caused by many thing. You're inputfile contains invalid data. If you use a comma as a fieldseparator, and one of the records contains a comma, bcp-out will succeed, but bcp-in will fail because the comma that is bcp-ed out will be treated as a field-separator and therefore try to put values in the wrong columns

    Try using a ; or something more exotic, like #@# as a fieldseparator.
    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
  •