SQL Update data in a column

Datebase is Produce_Deliveries
Table is Transactions
Column is Customers
Data is John Smith

I would like to change all instances of John Smith to Julie Anderson
Curtis LongAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Barry CunneyCommented:
You should always be cautious with updates.
In the sample code below you can first highlight SQL beginning WITH 'SELECT....' to get a count of the records which you intend to update.
Then if you are happy you can go ahead with the update - highlight SQL including the 'UPDATE...' ETC.
Also it is wise to wrap the update in a transaction and if you are happy that the correct update has been then you can COMMIT TRAN - or if there is a problem you can do ROLLBACK TRAN to cancel the update

SET [Customers] = 'Julie Anderson'
FROM [Transactions] AS t
WHERE [Customers] = 'John Smith'

Open in new window

Scott PletcherSenior DBACommented:
Sounds like homework?!  Is a real business really storing the actual client name in a transaction record?!
Curtis LongAuthor Commented:
Sorry Scott, Im not sure I understand your question and/or concern.
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Jim HornMicrosoft SQL Server Data DudeCommented:
USE Produce_Deliveries

UPDATE Transactions
SET Customers = 'Julie Anderson'
WHERE Customers = 'John Smith'

Open in new window

>Sorry Scott, Im not sure I understand your question and/or concern.
EE is not a homework site, so homework questions are not allowed, and this question resembles a 'Hello World' level of simplicity that smacks of homework.  We can help you understand concepts, but flat-out asking us to do homework for you reeks of academic dishonesty.

That, and we have *ways* of finding out what class people are taking that ask such questions.

The official EE homework policy is here.  Some unofficial color commentary on homework is here.  My highly-unofficial-and-very-funny 'How to ask better questions' article is here.
Curtis LongAuthor Commented:
Ahh, no, I know it is simple but it was easier to ask then figure out.  It is for a scale program at a company I work at.

Thanks!!  :-)
Curtis LongAuthor Commented:
When he said "Home work" all I could register was "Working at home"  Which I was doing and couldnt quite figure out how scott could have known this.  ;-)
Curtis LongAuthor Commented:
Ok, so this is what stired my initial question.

The query above doesnt seem to work.  This is what I get.
Curtis LongAuthor Commented:
And this is the table format
Scott PletcherSenior DBACommented:
"Transaction" is a reserved word -- that is, it has special meaning to SQL Server -- so when you use it as regular name, you must delimit it, for example:

UPDATE [Transaction]
SET Customer = '...'
WHERE Customer = '...'

If you want to play it safe, you can delimit every name:

UPDATE [Transaction]
SET [Customer] = '...'
WHERE [Customer] = '...'

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Curtis LongAuthor Commented:
BEAUTIFUL!!  Thanks!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.