|
|
|
Valued Member
      
Group: General Forum Members
Last Login: Monday, April 15, 2013 5:48 AM
Points: 67,
Visits: 212
|
|
Hi,
I have the following Coalesce Query
Coalesce (ProductClass,ProductColor,ProductID)
ProductClass and ProductColor are of the same datatype varchar , but the ProductID is of the Integer Data Type.
When I execute the query it gives the Data Conversion Error i.e. Cannot Convert from int to character data type.
Can anyone help me in resolving the same.
And also :
Where exactly one can use the Coalesce Function.
Thanks
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Thursday, May 02, 2013 5:38 AM
Points: 870,
Visits: 858
|
|
All data types in the coalesce function must be the same.
Try converting the ProductID into a varchar which has a length equal to the larger of productclass and productcolor.
e.g.
Coalesce (ProductClass,ProductColor,convert(varhchar(100), ProductID))
Kirman (8/27/2010) Hi,
I have the following Coalesce Query
Coalesce (ProductClass,ProductColor,ProductID)
ProductClass and ProductColor are of the same datatype varchar , but the ProductID is of the Integer Data Type.
When I execute the query it gives the Data Conversion Error i.e. Cannot Convert from int to character data type.
Can anyone help me in resolving the same.
And also :
Where exactly one can use the Coalesce Function.
Thanks
Karl source control for SQL Server
|
|
|
|