Reputation: 109
I have a question with converting data. I have a select query made in VBA, how can I convert from varchar
value column to nvarchar
.
I get this error:
Arithmetic overflow error converting numeric to data type numeric
This is my code:
Dim strSQL As String
Dim rst As New ADODB.Recordset
strSQL = " INSERT INTO dbo.Soferi_test (test1)" & _
" SELECT MySQL.dbo.sofieri.certificat_cipti " & _
" FROM MySQL.dbo.sofieri " & _
" WHERE IDNO = " & Forms!Forma_redactare_soferi!IDNO.Value
Call AttServ(strSQL, rst)
Upvotes: 0
Views: 2122
Reputation: 432667
Your int value is too big for the numeric precision and scale definition
Here, I guess the error comes from the WHERE clause. Not the INSERT
DECLARE @foo int = 99999;
DECLARE @n1 numeric(9,1), @n2 numeric (3,2);
-- 9,1 is 9 total digits, 1 decimal place
-- 3,2 is 2 total digits, 2 decimal places
-- 99999 requires at least 5 total digits
PRINT 'Wide enough'
SET @n1 = @foo;
PRINT 'Error'
SET @n2 = @foo;
After comment, the same still applies
DECLARE @foo numeric(5,0) = 99999;
DECLARE @n1 numeric(9,1), @n2 numeric (3,2);
PRINT 'Wide enough'
SET @n1 = @foo;
PRINT 'Error'
SET @n2 = @foo;
Upvotes: 1