November 3, 2006 at 9:00 am
Hi, I am trying to create a view to get ";" delimated data into one column. When I run it gives me a syntax error saying "error converting the varchar value to a column of data type int. Here is the code for my view. What am I doing wrong?
CREATE View VW_SUPPLYGROUPS
AS
select SupplyGroupSeqID + ';OHIER_NODE;' + SupplyGroupName + ';;' +
'0;E;' + SupplyGroupName + ';' +
SupplyGroupName + ';' + SupplyGroupName AS NODE
from SAPFIN.DBO.NCSupplyGroups
UNION
select AccountID + DeptID + ';ZACCDEP;' + AccountID + DeptID + ';;' + SupplyGroupSeqID +
';E;' + SupplyDescription + ';' + SupplyDescription + ';' + SupplyDescription
from SAPFIN.DBO.NCSupplyGroups
Thanks!
November 3, 2006 at 9:09 am
Hi ,
as you are using the field SupplyGroupSeqID which indicate and interger value and can not be concate with string. you need to convert this to string and this will work fine.
I have changed in the code let try and hope this will slove your problem
CREATE View VW_SUPPLYGROUPS
AS
select Cast(SupplyGroupSeqID as varchar) + ';OHIER_NODE;' + SupplyGroupName + ';;' +
'0;E;' + SupplyGroupName + ';' +
SupplyGroupName + ';' + SupplyGroupName AS NODE
from SAPFIN.DBO.NCSupplyGroups
UNION
select AccountID + DeptID + ';ZACCDEP;' + AccountID + DeptID + ';;' + SupplyGroupSeqID +
';E;' + SupplyDescription + ';' + SupplyDescription + ';' + SupplyDescripti
cheers
November 3, 2006 at 9:13 am
Sorry, but the code in the union class also need the same modification. I think you have got the problem... when ever you need to concate a string and numeric value you need to convert the numaric to character data type.
I hope this will slove your problem.
cheers
November 3, 2006 at 9:23 am
That works. Thank you for such a fast reply!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply