Insert and Update in one storedprocedure
I have a storedprocedure that I put the INsert and Update together in one store procedure. On my varaibles, I declared an @ID as integer
But my ID in my db is Autoincremented, now my problem is that whenever I tried to insert something, it complains that the ID doesn't supply. But during the insert, I don't need to insert the ID because it's auto increment, but I need the ID for the Update... how do I do this?
Re: Insert and Update in one storedprocedure
Always supply it in the SP check if > 0 then update if = 0 then Insert using an If condition on the @Id var pass the Id for the update or 0 for insert.
Re: Insert and Update in one storedprocedure
Thank you, but now I am having a problem with other variables that I declared in that SP as well when I have a SELECT * FROM tbl
It's asking me to provide those parameters like username, firstname, lastname, age, etc... how do I approach that?
Re: Insert and Update in one storedprocedure
Please post your code and the stored procedure before we go futher. With out seeing what you are doing there is no way to actually help you out here.