Link to home
Start Free TrialLog in
Avatar of J3D1-KN1G1-1t
J3D1-KN1G1-1t

asked on

SQL Query ISNULL with convert

Hi ALL,

Hows it going?

I have a simple question, I have this this query

ISNULL(itemID, 'Generic')

Which basically gives me an error message saying that I cant convert integer to 'Generic' and I know there is a convert or something similar I can use to convert integer into varchar.

Can you please tell me how to correctly write this code.

Cheers,

J3di
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Give this a whirl..

CAST(ISNULL(itemID, 'Generic') as varchar(25))
ASKER CERTIFIED SOLUTION
Avatar of Dale Burrell
Dale Burrell
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SELECT ISNULL(CAST(itemID AS VARCHAR(8)), 'Generic')

Open in new window

Avatar of J3D1-KN1G1-1t
J3D1-KN1G1-1t

ASKER

thanks Dale and Jim for the answer and thorough explanation