Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Coalesce Query Expand / Collapse
Author
Message
Posted Friday, August 27, 2010 4:57 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, June 19, 2014 12:02 AM
Points: 69, Visits: 228
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
Post #976278
Posted Friday, August 27, 2010 5:22 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, September 25, 2014 4:43 AM
Points: 870, Visits: 900
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
Post #976288
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse