View Single Post
  #1 (permalink)  
Old November 12th, 2011, 05:31 PM
NovicePGM2011 NovicePGM2011 is offline
Authorized User
Points: 53, Level: 1
Points: 53, Level: 1 Points: 53, Level: 1 Points: 53, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2011
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating a Record with Stored Procedure

This forum seemed like a party that died years ago!
However, I remain hopeful someone is still around to answer my question.

Chapter 10. Page 315 talks about performing updates using stored procedures.

Here is the piece of code I am referring to:
    @ContactID      int
  , @FirstName      nvarchar(50)
  , @LastName       nvarchar(50)
  , @Phone          nvarchar(25)
   UPDATE MyContacts 
   SET FirstName = @FirstName
     , LastName = @LastName
     , Phone = @Phone

spUpd_MyContacts 5, 'Betrice', 'Rubble', '(222) 234-7654'
When I run this code, it updates all the records in the table rather then only updating record with the ID of 1. Is this code suppose to update all records? Or just the record with primary key of 5?

My second question is, how do I update a record without using a primary key? Can I specify other attributes in a where clause rather then using a primary key?

Thanks everyone!


Last edited by NovicePGM2011; November 12th, 2011 at 05:54 PM.
Reply With Quote