Greetings,
I have been trying to use the DTS Import Wizard to import data, but SQL Server seems to have a bug that Microsoft has not yet addressed (or have they?)
Basically, when I import data from a text file into one of my existing databases that contains a field with an identity, I run into problems. Basically, SQL gives an error and refuses to import my data if the column is set to having an identity. In the Column Mappings, I set that row to "ignore." I also tried checking Enable Identity Insert, and I tried unchecking it. Nothing works. I receive this error message: "...The statement has been terminated. Cannot insert the value NULL into column 'MovieID', table 'myproject.dbo.MovieStars'; column does not allow nulls. INSERT fails."
I thought that checking "Enable Identity Insert" would automatically tell DTS to insert an incremental identity value.
When I use this transformation code, it doesn't work either:
Function Main()
DTSDestination("MovieName") = DTSSource("Col001")
DTSDestination("MovieStar") = DTSSource("Col002")
Main = DTSTransformStat_OK
End Function
This gives me a different but similar error: "Insert error, column 1, ('MovieID', DBTYPE_I4), status 10: Integrity violation; attempt insert NULL data or data which violates constraints. Unspecified error"
I think this is a SQL Server bug. My google searches have revealed MANY people with this similar problem, but their problem almost never gets answered. If anyone could please offer assistance, that would be great, as my head is turning black and blue from banging it on my desk for the past 3 days.
ThanksI don't think DTS is buggy you are using text file which have empty columns but IDENTITY is a primary key which cannot accept NULL, so I would import the data to a table without IDENTITY column and no key before moving it with an INSERT INTO statement to your destination table. The integrity violation is also primary key related because ANSI SQL rule primary key cannot accept NULL value but foreign key can. Yes your table will be denormalized but INSERT INTO will move the data to your destination table. Hope this helps.|||Thank you, your post is solely responsible for me getting around the problem. I put it into a temp table first, then into the main table. Thanks again!|||I am glad you got it working.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment