| Author |
Topic |
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2010-11-22 : 16:47:47
|
| I am running a simple insert.....Insert INTO Defaults (DefaultID, ProgramID, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDate)(select DefaultID, ProgramID+8669, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDateFrom rating_2.dbo.defaultsWhere ProgramID Between 1331 and 1420)and I have recieved this error....Msg 544, Level 16, State 1, Line 1Cannot insert explicit value for identity column in table 'Defaults' when IDENTITY_INSERT is set to OFF. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2010-11-23 : 09:11:43
|
| All I want to do is copy all the information and set it with a new programid that is 8669 higher then the one I am copying. How would I change this to a Set Identity_Insert and what would that do? Thanks for the help!Best,GGInsert INTO Defaults (DefaultID, ProgramID, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDate)(select DefaultID, ProgramID+8669, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDateFrom rating_2.dbo.defaultsWhere ProgramID Between 1331 and 1420)Insert INTO Defaults (DefaultID, ProgramID, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDate)(select DefaultID, ProgramID+90, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDateFrom rating_2.dbo.defaultsWhere ProgramID Between 10000 and 10089) |
 |
|
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2010-11-23 : 09:20:53
|
| set identity_insert Defaults onInsert INTO Defaults (DefaultID, ProgramID, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDate)(select DefaultID, ProgramID+8669, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDateFrom rating_2.dbo.defaultsWhere ProgramID Between 1331 and 1420)Insert INTO Defaults (DefaultID, ProgramID, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDate)(select DefaultID, ProgramID+90, CoverageID, InclAmt, CalcType, MinLimit, LimitID, Territory, RateEffectiveDate, RateExpirationDateFrom rating_2.dbo.defaultsWhere ProgramID Between 10000 and 10089)set identity_insert Defaults off==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2010-11-23 : 09:26:30
|
| Thank you. |
 |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2010-11-23 : 09:33:41
|
| I recieved this error. Also I did not have to do somthing like that before. say i have ten rows of data each with a unique programid 1-10. What I want is that data copied in that table and then have the programid change to 30 -31. so I now have programid 1-10, and 30-31 that have the exact same data just different programids.......thanks for the help.Msg 2627, Level 14, State 1, Line 3Violation of PRIMARY KEY constraint 'PK_Defaults'. Cannot insert duplicate key in object 'dbo.Defaults'.The statement has been terminated.(0 row(s) affected)(0 row(s) affected)(0 row(s) affected)(0 row(s) affected)(0 row(s) affected)(0 row(s) affected)(0 row(s) affected) |
 |
|
|
JJins
Yak Posting Veteran
81 Posts |
Posted - 2010-11-23 : 09:40:45
|
| I figured it out! thanks for all your help.Best,GG |
 |
|
|
|
|
|