Click here to Skip to main content
15,894,825 members
Home / Discussions / Database
   

Database

 
AnswerRe: Specifying Seed Values on model building Pin
R. Giskard Reventlov18-Sep-12 8:22
R. Giskard Reventlov18-Sep-12 8:22 
AnswerRe: Specifying Seed Values on model building Pin
Eddy Vluggen21-Sep-12 4:52
professionalEddy Vluggen21-Sep-12 4:52 
Questionmultiple data instances one machine Pin
John Robert Wilk17-Sep-12 8:15
John Robert Wilk17-Sep-12 8:15 
AnswerRe: multiple data instances one machine Pin
Jörgen Andersson17-Sep-12 8:55
professionalJörgen Andersson17-Sep-12 8:55 
AnswerRe: multiple data instances one machine Pin
Wes Aday17-Sep-12 9:01
professionalWes Aday17-Sep-12 9:01 
GeneralRe: multiple data instances one machine Pin
John Robert Wilk17-Sep-12 9:08
John Robert Wilk17-Sep-12 9:08 
GeneralRe: multiple data instances one machine Pin
Wes Aday17-Sep-12 9:14
professionalWes Aday17-Sep-12 9:14 
GeneralRe: multiple data instances one machine Pin
John Robert Wilk17-Sep-12 9:17
John Robert Wilk17-Sep-12 9:17 
GeneralRe: multiple data instances one machine Pin
Wes Aday17-Sep-12 9:23
professionalWes Aday17-Sep-12 9:23 
AnswerRe: multiple data instances one machine Pin
jschell17-Sep-12 9:16
jschell17-Sep-12 9:16 
GeneralRe: multiple data instances one machine Pin
John Robert Wilk17-Sep-12 9:21
John Robert Wilk17-Sep-12 9:21 
GeneralRe: multiple data instances one machine Pin
jschell18-Sep-12 8:00
jschell18-Sep-12 8:00 
AnswerRe: multiple data instances one machine Pin
Eddy Vluggen21-Sep-12 4:54
professionalEddy Vluggen21-Sep-12 4:54 
QuestionSQL Error - Insert happening on update Pin
loctrice17-Sep-12 7:32
professionalloctrice17-Sep-12 7:32 
I have a stored procedure that is updating, but causing an insert error. Never seen that before.

SQL
Update MyCoolTable
Set MyValue=@passedInValue, SecondaryIdentifier=@secondID 
WHERE PrimaryID = @primaryID


There is an index on (SecondaryID,PrimaryID) that is being violated and I'm not sure why. :

Quote:
Cannot insert duplicate key in object 'dbo.MyCoolTable'. The duplicate key value is (secondaryIDValue, primaryIDValue).



Why is it trying to insert on an update?


--edit--

Nevermind, I figured out what was happening (though not from the error message). It can't update the secondaryID because there can be more than one, which is what is causing the problem. I guess when they wrote it that could never ever happen.
If it moves, compile it


modified 17-Sep-12 13:41pm.

AnswerRe: SQL Error - Insert happening on update Pin
Andrei Straut17-Sep-12 7:44
Andrei Straut17-Sep-12 7:44 
GeneralRe: SQL Error - Insert happening on update Pin
loctrice17-Sep-12 7:51
professionalloctrice17-Sep-12 7:51 
GeneralRe: SQL Error - Insert happening on update Pin
Andrei Straut17-Sep-12 7:54
Andrei Straut17-Sep-12 7:54 
GeneralRe: SQL Error - Insert happening on update Pin
loctrice17-Sep-12 7:56
professionalloctrice17-Sep-12 7:56 
Questionmy SQl Pin
sreenadhmn16-Sep-12 23:16
sreenadhmn16-Sep-12 23:16 
AnswerRe: my SQl PinPopular
Andrei Straut16-Sep-12 23:54
Andrei Straut16-Sep-12 23:54 
GeneralRe: my SQl Pin
Mycroft Holmes17-Sep-12 2:15
professionalMycroft Holmes17-Sep-12 2:15 
GeneralRe: my SQl Pin
Andrei Straut17-Sep-12 2:27
Andrei Straut17-Sep-12 2:27 
GeneralRe: my SQl Pin
Richard MacCutchan17-Sep-12 4:44
mveRichard MacCutchan17-Sep-12 4:44 
GeneralRe: my SQl Pin
Andrei Straut17-Sep-12 5:26
Andrei Straut17-Sep-12 5:26 
GeneralRe: my SQl Pin
Jörgen Andersson17-Sep-12 8:50
professionalJörgen Andersson17-Sep-12 8:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.