Error converting ntext to text
Nazca_Aaron
Posts: 12
Background info: I am using DC 5.1.0.106. Database is SQL 2000.
I have a table in a database that has a text field, which basically holds XML text. When I do a Data Compare and try to execute the resulting SQL script, I get the error:
Msg 518, Level 16, State 1, Line 3
Cannot convert data type ntext to text.
The statement has been terminated.
I poked around and found a MS bug article that talked about the above error, saying "If you attempt to use an UPDATETEXT statement to convert TEXT to NTEXT (the UNICODE equivalent to TEXT) or vise versa, you will receive the following error: " , followed by my error. I am not sure that I can take out the UPDATETEXT statement in the SQL generated by DC.
If I run the same compare with DC 4.0.0.110 and execute the resulting SQL script, I do not get any errors.
Is there a work around for this? There is a suggestion in the MS article, but I'd rather have the workaround scripted with DC instead of editing the script by hand.
Otherwise, I am finding DC (and SQL Compare) to be an invaluable tool
I have a table in a database that has a text field, which basically holds XML text. When I do a Data Compare and try to execute the resulting SQL script, I get the error:
Msg 518, Level 16, State 1, Line 3
Cannot convert data type ntext to text.
The statement has been terminated.
I poked around and found a MS bug article that talked about the above error, saying "If you attempt to use an UPDATETEXT statement to convert TEXT to NTEXT (the UNICODE equivalent to TEXT) or vise versa, you will receive the following error: " , followed by my error. I am not sure that I can take out the UPDATETEXT statement in the SQL generated by DC.
If I run the same compare with DC 4.0.0.110 and execute the resulting SQL script, I do not get any errors.
Is there a work around for this? There is a suggestion in the MS article, but I'd rather have the workaround scripted with DC instead of editing the script by hand.
Otherwise, I am finding DC (and SQL Compare) to be an invaluable tool
I hook up data.
This discussion has been closed.
Comments
In DC 5, the compare results in 3 tables that do not compare properly, and I need to manually set the key to get them to compare, after which the compare works fine (until I run the SQL script, that is).
In DC 4, these 3 tables do not even show up in the compare, and there is no option that I know of to manually set the key, as in DC 5. So, the compare with DC 4 works because it doesn't script the problem table at all, and thus the SQL script has no errors.
My assertion that the script works under DC4 but not DC5 is technically correct, but very misleading, so please disregard.
The column is of the type ntext in the dirst database table, and text in the second? Are there any Unicode (double-byte) characters in the script?
The SQL statements that fail look something like:
whereas statements updating the same table that appear to work are basic INSERT INTO statements (i.e.
It seems as if a single record is being split into two different statements for some reason: an INSERT INTO and an EXEC('INSERT INTO...). Hopefully that makes at least a little sense? :?
We think this could be a bug in the software to do with bounds checking that would cause SQL Compare to improperly use UPDATETEXT if the length of the column is exactly a multiple of 4000.
Can you please retry the compare and synchronize using the 'trim trailing spaces' option?
Thanks!
There are 9 records in the table I am attempting to script. The first 8 records do not use UPDATETEXT in the script, and they run just fine. However, the last record has a text field that is significantly longer than the others (i.e. there is more actual text in the field). This record is the one causing the script to fail.
As it is a text field, I cannot do a LEN(field) to find the length. If I convert the column to a VARCHAR(8000), the length returns 8000. I suspect the text field is actually longer than that, but max VARCHAR length is 8000.
Thanks for all your help, Brian.
Can't think of anything else. Can you please send backups of the databases to support@red-gate.com?
Thanks!