View Single Post
  #7 (permalink)  
Old November 12th, 2011, 10:15 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

Originally Posted by Paul_Turley View Post
If you wanted to use the first and last name to identify the record and also have the ability to pass in new values for the same two columns, you could do this:

create procedure spUpd_ContactName
@FirstName nvarchar(50)
, @LastName nvarchar(50)
, @NewFirstName nvarchar(50)
, @NewLastName nvarchar(50)
update MyContacts
set FirstName = @NewFirstName, LastName = @NewLastName
where FirstName = @FirstName and LastName = @LastName
Here is what I did per your directions to update the table or a record without changing the name. Meaning I used the Store Name and the Store Branch in the where clause to update the table.

  @StoreName    VARCHAR(30)
, @StoreBranch  VARCHAR(30)
, @StoreAddress VARCHAR(30)
, @StoreCity    VARCHAR(30)
, @StoreState      CHAR(2)
, @StoreZip        CHAR(9)
, @StorePhone      CHAR(10)
UPDATE tblStore
SET StoreAddress = @StoreAddress
  , StoreCity    = @StoreCity
  , StoreState   = @StoreState
  , StoreZip     = @StoreZip
  , StorePhone   = @StorePhone
WHERE StoreName  = @StoreName AND StoreBranch = @StoreBranch

spUpd_StoreInfo 'Maple Grove', 'Best Buy','99689 Ruggs Street', 'Minneapolis', 'MN',
Thanks for your help!
Reply With Quote