|
-
Jul 16th, 2009, 01:02 PM
#1
Thread Starter
Frenzied Member
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?
-
Jul 16th, 2009, 01:17 PM
#2
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
-
Jul 16th, 2009, 03:38 PM
#3
Thread Starter
Frenzied Member
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?
-
Jul 16th, 2009, 05:44 PM
#4
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.
Sometimes the Programmer
Sometimes the DBA
Mazz1
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|