converting of datatypes problem
hi guys i want a column name billing address. so in that i need to have all the fields. below i am giving the my query (pa.AddressID+pa.AddressLine1+isnull(pa.AddressLine2,' ')+pa.City+sp.Name+cr.Name) as billto, (pa1.AddressID+pa1.AddressLine1+isnull(pa1.AddressLine2,' ')+pa1.City+sp1.Name+cr1.Name) as shipto all tables are from adventure works when i am excecuting the query the following error is occured Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the nvarchar value 'Albania' to data type int. please help me to resolve this
February 10th, 2012 3:02am

Your first column is of type int so you have to do this (Convert(pa.AddressID,varchar(10))+pa.AddressLine1+isnull(pa.AddressLine2,' ')+pa.City+sp.Name+cr.Name) as billto, (Convert(pa1.AddressID,varchar(10))+pa1.AddressLine1+isnull(pa1.AddressLine2,' ')+pa1.City+sp1.Name+cr1.Name) as shipto -------------------------------------------------------- Surender Singh Bhadauria My Blog
Free Windows Admin Tool Kit Click here and download it now
February 10th, 2012 3:12am

hi, try this (Cast(pa.AddressID as varchar(MAx))+pa.AddressLine1+isnull(pa.AddressLine2,' ')+pa.City+sp.Name+cr.Name) as billto, (cast (pa1.AddressID as varchar(max))+pa1.AddressLine1+isnull(pa1.AddressLine2,' ')+pa1.City+sp1.Name+cr1.Name) as shiptoHope this will help you !!! Sanjeewan
February 10th, 2012 3:14am

Your first column is of type int so you have to do this (Convert(pa.AddressID,varchar(10))+pa.AddressLine1+isnull(pa.AddressLine2,' ')+pa.City+sp.Name+cr.Name) as billto, (Convert(pa1.AddressID,varchar(10))+pa1.AddressLine1+isnull(pa1.AddressLine2,' ')+pa1.City+sp1.Name+cr1.Name) as shipto -------------------------------------------------------- Surender Singh Bhadauria My Blog
Free Windows Admin Tool Kit Click here and download it now
February 10th, 2012 10:55am

hi, try this (Cast(pa.AddressID as varchar(MAx))+pa.AddressLine1+isnull(pa.AddressLine2,' ')+pa.City+sp.Name+cr.Name) as billto, (cast (pa1.AddressID as varchar(max))+pa1.AddressLine1+isnull(pa1.AddressLine2,' ')+pa1.City+sp1.Name+cr1.Name) as shiptoHope this will help you !!! Sanjeewan
February 10th, 2012 10:57am

Thank You
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2012 8:36am

Thank You
March 14th, 2012 8:36am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics