16
Implicit conversion from datatype '%s' to '%s' is not allowed. Use the CONVERT function to run this query.
When performing certain types of comparisons, and while storing and retrieving data, Adaptive Server automatically handles many conversions from one datatype to another. These are called implicit conversions. You can explicitly request other conversions with the convert, inttohex, and hextoint functions.
Error 257 is raised when Adaptive Server is unable to do an implicit conversion because of incompatibilities between datatypes.
Corrective action depends on the exact situation in which the error occurred. Here are some typical situations where error 257 is raised, and how you can correct the problem:
If you attempt to perform comparisons on integer data with the like keyword; you must use the convert function on integer data if you want Adaptive Server to treat it as character data for comparisons.
If you are using embedded SQL, and Adaptive Server is unable to perform an implicit conversion between a database column and the corresponding host language variable. Consider using a different host variable to accomplish the conversion. For example, in a COBOL application, a column of money datatype requires a COMP-2 host variable.
If you attempt to insert quoted values for integer data. For example the following input raises error 257:
1> create table citycodes 2> (cityname char(12), citycode smallint) 3> go
1> insert into citycodes 2> values ('Detroit', '123') 3> go
Quotes are not allowed around the city code in this insert statement.
When a statement implicitly exceeds the maximum
length of a character datatype. For example, columnX is
defined as varchar(255
).
If you submit a query like this:
1> select * from tableX 2> where columnX like '.....%'
and there are 255 characters preceding “%
”,
error 257 is raised. Adaptive Server treats the comparison string
as if it contains more than 255 characters and assumes that it is
a TEXT datatype, which it cannot implicitly convert.
For detailed information about datatype conversions, see the section “Datatype conversion functions” in the chapter “Using the Built-In Functions in Queries” in the most recent Transact SQL User’s Guide.
Before calling Technical Support, have the information on hand listed in “Reporting errors”, including the SQL statement that generated the error.
All versions