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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
--
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)