Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error converting data type nvarchar to numeric. 1

Status
Not open for further replies.

willdevelope

Programmer
Nov 18, 2005
25
US
**The query will select the data fields find if I comment out the where clause but I am trying to compare two fields LOCATION_INVENTORY.onhandqty and ITEM.STORAGE_TEMPLATE if data LOCATION_INVENTORY.onhandqty don't match ITEM.STORAGE_TEMPLATE show me data.But if i remove where clause it will give me the selected data but not the way I need it to compare two fields. With where clause error out***Error converting data type nvarchar to numeric.***


SELECT
dbo.LOCATION_INVENTORY.ITEM,
dbo.ITEM.DESCRIPTION,
sum(dbo.LOCATION_INVENTORY.ON_HAND_QTY) as TotalonHandQty,
dbo.ITEM.ITEM_CLASS
FROM
dbo.LOCATION_INVENTORY
INNER JOIN dbo.ITEM ON (dbo.LOCATION_INVENTORY.ITEM = dbo.ITEM.ITEM)
--WHERE
--(dbo.LOCATION_INVENTORY.ON_HAND_QTY != dbo.ITEM.STORAGE_TEMPLATE)
group by dbo.LOCATION_INVENTORY.ITEM,
dbo.ITEM.DESCRIPTION,
dbo.ITEM.ITEM_CLASS


 
I assume that On_Hand_Qty is a numeric field while Storage_Template is character (nvarchar). What data do you have in that field? Can you try to use explicit cast, e.g.

where dbo.LOCATION_INVENTORY.ON_HAND_QTY != CAST(dbo.ITEM.STORAGE_TEMPLATE as Numeric(7,2))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top