Showing posts with label equal. Show all posts
Showing posts with label equal. Show all posts

Friday, March 23, 2012

Error on SQL .mdf update and edit - nText?

Hello anyone know how to fix this error?

The data types ntext and nvarchar are incompatible in the equal to operator.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.Data.SqlClient.SqlException: The data types ntext and nvarchar are incompatible in the equal to operator.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Thanks , John

An nText field can not be used in optimisitic updates. Your update statement that was generated looks something like:

UPDATE SomeTable
SET {Stuff}
WHERE nTextField=old_nTextField

And old_nTextField is defined as a nvarchar. You can't really define it as nText as nText is just a very long nvarchar field, and even if you COULD get it defined as a nText, it would still be invalid, because you can't use nText= anything, even another nText in a WHERE clause.

|||What should it be? I am now using a text , but it still does not work.|||

TEXT/NTEXT/IMAGE data in SQL Server are considered as BLOB (Binary Large Object) data and can not be used with "=" or in sorting. You may need "Text and Image Functions" to manipulate these kinds of data:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_fa-fz_0gs3.asp

Or you can convert the TEXT data (less than 8000 chars) into VARCHAR data to use it in comparation, for example:

select * from test_txt where convert(varchar(8000),t)='The index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is 0.'

Or use LIKE operator:

select * from test_txt where t like 'The index position of the value parameter if that string is found, or -1 if it is not. If value is Empty, the return value is 0.'

Wednesday, February 15, 2012

Error message

Hello,

When I try to run a query on a server, I get the following error:

"Cannot resolve collation conflict for equal to operation."

The same query, but on another server works without any problems.

Any idea how I can resolve this?You are joining two different coallations which each other. To solve the collation conflict you will have to either change the collation on the server / database / table / or expression server you are using (whereas the latter is the quickfix for your problem. It has be to implemented whereever you are joining different collations:

select ca.account_status, cs.code from customer as ca
inner join v_customer_status as cs on ca.account_status = cs.description COLLATE SQL_Latin1_General_CP1_CI_AI

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de|||Thanks Jens.

But the query contains tables of the same database.|||That is not just related to different databases. Also just columns within a table can have a different collation. QUery the INFORMATION_SCHEMA.Columns to see which Collation they have and use the mentioned keyword and syntax to use a common collation.

HTH, Jens.|||txs Jens.

I saw some different entries in the syscolumns under the field collation.
Unfortunately I cannot change the collation name.

What can I do (apart from changing my queries)?|||Is there any specific reason why you have different collation settings for tables in the same database? Unless you're willing to "sweat it out" the easiest way is to change the collation settings of one table to be the same as the other.|||I copied the tables from another server, apparently with a different collation setting.

How can I change this setting per table?|||I think there is no command for changing every column within the table. YOu will have to change this by column with the command:

ALTER TABLE <tablename> ALTER COLUMN colname <datatype> COLLATE <collationname>

HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de