April 16, 2009 at 7:26 am
I am trying to do an insert from one table to another where for one column the destination table expects a numerice value while the source table column is a nvarchar(MAX). So I receive an Error converting data type nvarchar to numeric. How can I solve this issue?
INSERT INTO dbo.TABLE1
(
Name
, LastDate
, Price
)
SELECT
Name = item_name
, LastDate = getdate()
, Price = field1
FROM TABLE2
Column Price is a decimal(18,5) and column field1 is a nvarchar(MAX).
Thanks.
April 16, 2009 at 7:44 am
can you convert it to decimal?
'price' = convert(decimal(18,5),field1)
April 16, 2009 at 7:48 am
When I try to convert to int CONVERT (INT, field1) I get the following message:
Conversion failed when converting the nvarchar value '15.500' to data type int.
April 16, 2009 at 8:07 am
OJDev (4/16/2009)
When I try to convert to int CONVERT (INT, field1) I get the following message:Conversion failed when converting the nvarchar value '15.500' to data type int.
This is because the INT datatype only supports whole numbers, to convert 15.500 you will need to choose a data type that supports decimals such as Numeric..
April 16, 2009 at 8:09 am
sorry, you must have read my post before i edited it. my previous post on here is correctly showing as a convert to decimal now.
April 16, 2009 at 8:23 am
actually, while i'm here, why do i have a delete button available on this forum for the posts of other people? if i click to delete someone elses posts will it delete or will it just deny me?
April 22, 2009 at 2:01 pm
Lately, it won't even let you delete your own post.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply