We have a table with identity column, InsertID, which is decimal (18, 0) NOT NULL. I got an error "arithmetic overflow error converting varchar to data type numeric" with "SET IDENTITY_INSERT tablename ON" when running the following statements in SQL 2012:
SET IDENTITY_INSERT tablename ON ;
EXEC sp1;
SET IDENTITY_INSERT tablename OFF ;
------------------
Stored procedure sp1 statement is as follows:
INSERT INTO tablename (colnumn1, column2, ...., InsertID, ......)
SELECT col1, col2, .... ,
CASE WHEN case1 THEN 1
WHEN case2 THEN 6
WHEN case3 THEN 23
ELSE @unknownNumber
END AS InserId,
....
FROM tablelist
------------------
The table we are going to insert data has 1 million records. The table we select data from has 2 millions rows.
Any suggestions would be greatly appreciated.