Link to home
Start Free TrialLog in
Avatar of sqldba2013
sqldba2013

asked on

Error converting data type nvarchar to numeric - sql server

Please guide me how to resolve below error in below update statement.

Error: Error converting data type nvarchar to numeric.

update  dbo.#temp set [Sales Order $ to date]='$' + ' ' + cast(cast((SELECT TOP 1 SUM([SO Net Value]) FROM bcamdb.dbo.SAP_ZVBAK BAKSales with(nolock)
inner join  dbo.#temp on BAKSales.[Customer PO] LIKE LTRIM(CAST(dbo.#temp.[CPO Number] as varchar(50)))+'%') AS DECIMAL (18,2)) AS nvarchar(50))

Please find the attached #temp table structure.
temp-table
ASKER CERTIFIED SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada 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
OR remove the concatenation with '$' as you are building the temp table, but at output add the dollar symbol.

If you are doing calculations on those columns you would want to keep those fields as decimals I think.

Whichever logic you adopt, you will want to apply it consistently to the money fields:

          , [Sales Order $ to date] decimal(18, 2)
...
          , [Invoice $ to date] decimal(18, 2)
...
          , [Invoice $ Delta] decimal(18, 2)
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
Avatar of sqldba2013
sqldba2013

ASKER

--