View Single Post
  #5 (permalink)  
Old November 12th, 2011, 08:32 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
Thanks again. In my Scenario, the First Name and Last names are primary Keys. This scenario is just an example.

In the real world, the name could be a company name, example: BestBuy.
Since we are not going to be changing the company name, we make the name the primary Key.

However, I want to update all other fields using one or multiple attributes.
Example: Where company name = 'BestBuy' and Company Location = 'MPLS'.

This way we can update the address phone numbers but not the name. This scenario is perfect if there is only one branch per city.

By the way, how would I called the example you mentioned above?
I don't want to change the name but instead is it as an attribute in the Where clause.

Thanks a Million!


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