BCP Import with Integer

  • I am using BCP to import some files into a table, everything seems to be working fine except for my SQLINT column. When the number is inserted into the table it is inserting a different number. I have narrowed it down to the ASCII value for the character of the number (ie. 0=48, 1=49, 2=50).

    I have noticed people talking about native format but when I use the -c parameter it overrides my format file. Can anyone help?

    The column in the table is Integer and the format in the .fmt file is SQLINT.

  • Change to SQLCHAR in your format file.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • That worked!! Thanks!

    Can you explain why it worked? Shouldn't it be SQLINT if it is going to an INTEGER column?

  • I think it is to do with for format of the input file. You're data is in character format and therefore you need to tell bcp that. To use SQLINT in the format file the data would have to be in binary e.g. 0x30 instead of 0x3438 (ASCII 52 56) '48'

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Makes sense. Thanks again. I thought I was going to have to do some sort of hack trigger that converted it to it's CHAR value.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply