Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2005-10-31 : 09:58:49
|
| I want to copy a record to a new record in the same table, changing one of the fields. My sp below is doing this, but is also changing the value BookingNo in my record I am copying from, to the new @strBookingNo that I want in my new record. The purpose of this operation is that I have a menu order that my user can select to repeat. So, I just want to copy the original order to a new one, just changing the BookingNo to the new number. The sp is called from a webpage.CREATE PROCEDURE spRB_CopyMenuBooking@strBookingNotoCopy int,@strBookingNo intASINSERT INTO tblRB_MenuBookings(MB_BookingNo,MB_Item,MB_TimeRequired,MB_LedgerCode,MB_NoFor)SELECT @strBookingNo,MB_Item,MB_TimeRequired,MB_LedgerCode,MB_NoForfrom tblRB_MenuBookings WHERE MB_BookingNo = @strBookingNotoCopyGO |
|
|
nathans
Aged Yak Warrior
938 Posts |
Posted - 2005-10-31 : 13:26:25
|
| How do you populate @strBookingNo ?You should only be passing in @strBookingNotoCopy, then use an identity or similar routine to generate the "new" column MB_BookingNo.If you are passing in a unique MB_BookingNo as strBookingNo you should be doing a new row insert. I dont see where you would be updating the existing record in this code.Nathan Skerl |
 |
|
|
|
|
|
|
|