Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

SET IDENTITY_INSERT ON failed

$
0
0

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.


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>