I am using the bcp command to export a bulk text file into the database,
bcp elearning.dbo.BulkData in mobile.txt -c -t, -SZOHL-02 -Usa -P1234567890 -E
I have 6 fields in the table to which i am exporting data.
One field is numeric and i have to set the identity to yes,
It gives me an error string data trucncated. When i remove the identity field, i am able to export data.So, how do i tackle this prob?
I used the -E attribute to keep the identity .But still i get the error. The text file has comma seperated fields.
I am using sql server 2000
You have to import your data to a temp table or an intermediate table before moving the data to the table with IDENTITY because a text file will appear to have NULL primary key and IDENTITY which is a primary key cannot be NULL. And no it is not a bug but just the nature of a text file compared to tabular data in a database. Hope this helps.
没有评论:
发表评论