August 15, 2012 at 1:36 pm
I got "Conversion failed when converting the nvarchar value to data type int" error when I execute below SQL.
I guess nvarchar value maybe warranty field and try to write to data type int.
please tell me which part of sql was wrong.
SELECT DISTINCT TOP (100) PERCENT PONumber, Warranty, ISNULL(Warranty,'0') - DATEDIFF(day, Received, GETDATE()) AS WarrantyLeft FROM dbo.partlist WHERE (Warranty IS NOT NULL) AND (isnumeric(Warranty) ='1') AND (Received IS NOT NULL) GROUP BY PONumber, Warranty, Received ORDER BY PONumber
August 15, 2012 at 1:47 pm
wooricom (8/15/2012)
I got "Conversion failed when converting the nvarchar value to data type int" error when I execute below SQL.I guess nvarchar value maybe warranty field and try to write to data type int.
please tell me which part of sql was wrong.
SELECT DISTINCT TOP (100) PERCENT PONumber, Warranty, ISNULL(Warranty,'0') - DATEDIFF(day, Received, GETDATE()) AS WarrantyLeft FROM dbo.partlist WHERE (Warranty IS NOT NULL) AND (isnumeric(Warranty) ='1') AND (Received IS NOT NULL) GROUP BY PONumber, Warranty, Received ORDER BY PONumber
You may want to read this article: http://www.sqlservercentral.com/articles/IsNumeric/71512/
August 15, 2012 at 2:03 pm
Apart from Lynn recommendation, you don't need to add "ISNULL(Warranty,'0')" if you have "WHERE (Warranty IS NOT NULL)".
This won't solve your problem (in the article they show your possible solution) but it's just a simple observation.
August 15, 2012 at 2:55 pm
:-):-)
Thank Lynn Pettis and Luis Cazares,
I fixed this problem, I use IsAllDigites function instead of using isnumeric function.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply