Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Negative number to numeric table results in error

Author  Topic 

robert_645
Starting Member

4 Posts

Posted - 2015-04-10 : 09:00:49
Hello,

I have an Excel/ vba module to update a SQL database. One of the data is numeric. If the data is a positive number, there is no problem, but if the number (zscore) in Excel is negative an error pops up: Error converting datatype varchar to numeric.


zscore = Range("J" & mytel99)


rc.Open "INSERT INTO dbo.QHSE_3rdline_history (RvA_Nr, RvA_Letter, Afdeling, Datum, Organisator, NummerRO, Eenheid, ALC, RO, Interpretatie) " _
& "VALUES ('" & rva1 & "', '" & rva2 & "', '" & Range("B" & mytel99) & "', '" & datum & "', '" & Range("B1") & "', '" & Range("B2") & "', '" & Range("G" & mytel99) & "', '" & Range("H" & mytel99) & "', '" & Range("I" & mytel99) & "', '" & Range("K" & mytel99) & "')", con
rc.Open "UPDATE dbo.QHSE_3rdline_history SET [Matrix] = '" & Range("C" & mytel99) & "', [Component] = '" & Range("D" & mytel99) & "', [Zscore] = '" & zscore & "' WHERE ([RvA_Nr] = '" & rva1 & "' AND [RvA_Letter] = '" & rva2 & "' AND [Afdeling] = '" & Range("B" & mytel99) & "' AND [Datum] = '" & datum & "' AND [Organisator] = '" & Range("B1") & "' AND [NummerRO] = '" & Range("B2") & "' AND [Eenheid] = '" & Range("G" & mytel99) & "' AND [ALC] = '" & Range("H" & mytel99) & "' AND [RO] = '" & Range("I" & mytel99) & "' AND [Interpretatie] = '" & Range("K" & mytel99) & "')", con


Does anybody knows how to get negative data in a numeric SQL table?
Thanks in advance!

MichaelJSQL
Constraint Violating Yak Guru

252 Posts

Posted - 2015-04-10 : 09:30:48
you might try
https://social.msdn.microsoft.com/Forums/office/en-US/home?forum=exceldev
or
http://www.excelforum.com/
Go to Top of Page
   

- Advertisement -