The data types varchar(max) and text are incompatible in the equal to operator. in SQL Server2005 how to solve?

while(rs.next())
{
    String key=rs.getString(1);
    String val=rs.getString(2);       
    it=ar1.get(k).toString();
    if(it.trim().equals(key.trim()))   
    {
        val=val.substring(1);
        val=val+"1";
    }
    else
    {
        val=val.substring(1);
        val=val+"0";
    }

    st = con.prepareStatement("update win set seq=? where keyy=?");
    st.setString(1,val);
    st.setString(2,key); //here i am getting exception
    st.executeUpdate();
    st.close();
}

if i change data type of seq and keyy in table as text then it shows The data types text and text are incompatible in the equal to operator

  • Store tiff images in SQL Server or file system?
  • Aggregative sum of objects belonging to objects residing inside hierarchy structure
  • How to compare datetime with only date in SQL Server
  • Audit each inserted row in a Trigger
  • “The active result contains no fields” using PDO with MS SQL
  • Find unique values in a column of comma separated text
  • Converting SQL Server varBinary data into string C#
  • Convert SQL Server DateTime object to BIGINT (.Net ticks)
  • How to filter SQL Server 2008 Profiler Output for a single database?
  • What is the Reason large sites don't use MySQL with ASP.NET?
  • How to generate Entity Relationship (ER) Diagram of a database using Microsoft SQL Server Management Studio?
  • Sql query, selecting on unique identifier gives - Error converting data type varchar to uniqueidentifier
  • One Solution collect form web for “The data types varchar(max) and text are incompatible in the equal to operator. in SQL Server2005 how to solve?”

    Haven’t messed with TEXT data type in forever. But, leaving aside the questions about the wisdom of text “key” columns, you’ll need to use like. You cannot use standard comparison operators on TEXT and NTEXT (=,<=, etc).
    You can leave out the wildcards, so it’ll behave like an exact match. So if your keyy column is text:

    update win set seq=? where keyy like ?
    

    BTW, TEXT and NTEXT have been deprecated for several versions of SQL Server, I’m sure that one of these days they’re going to drop it. You should probably look into converting to CHAR and VARCHAR.

    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.