Click to See Complete Forum and Search --> : bcp command


aquafin
September 29th, 2005, 12:00 AM
I am using the bcp command to export a 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
I am using sqls erver 2000

exterminator
October 7th, 2005, 07:15 PM
The most probable cause of this could be lying in the text file data that you are having and the option that you are choosing. The data file would be having values for the identity columns and you are trying to tell the database either to use those values or to ignore those values and generate the identity column value automatically. Here is a quote from MSDN on this:-E:
Specifies that the values for an identity column are present in the file being imported. If -E is not given, the identity values for this column in the data file being imported are ignored, and SQL Server 2000 automatically assigns unique values based on the seed and increment values specified during table creation. If the data file does not contain values for the identity column in the table or view, use a format file to specify that the identity column in the table or view should be skipped when importing data; SQL Server 2000 automatically assigns unique values for the column.You might want to look up about format files here - Using Format Files (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_impt_bcp_9yat.asp). Regards.