Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 The data types char and text are incompatible in t

Author  Topic 

satwant17
Starting Member

1 Post

Posted - 2009-09-23 : 19:54:17
I am trying to create a Store Proc and in the Where Clause i n Comparing a column using "IN" but i get this error "The data types char and text are incompatible in the equal to operator."
I have tried converting and casting the column wot char, varchar,nvarchar, error goes away but no result.

And if i run the IN subquery and copy /paste the result "IN" it works perfectly fine and give the valid result
any help on this issue will be appriciated
Thanks
Satwant

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2009-09-24 : 13:53:47
This might be easier to diagnose with example table definition and query syntax, but here are a couple of things to consder to start...

Text is a large object data type and there is special syntax usually required for dealing with those. If you really need that large of a data type, you'll probably also want to use Full Text indexing and its associated query techniques.

CHAR is a fixed-length data type, which means that if your data does not take up all the space that is defined, then it will get padded with spaces to the end of the size. If your comparison does not have exactly the same number of spaces, it will fail. In this case, consider using the LIKE comparison, or converting the datatype to varchar instead.

--------------------------------------------
Brand yourself at EmeraldCityDomains.com
Go to Top of Page
   

- Advertisement -