We help IT Professionals succeed at work.
Get Started

In mssql what is the best way to update  field1 based on field2 where field3 is search field all in same row

Last Modified: 2012-05-09
What is the best way to update a field in a row by another field in the same row?

I have a table1 where columns are:   recid, field1, field2, field3  and recid is keyfield
Problem: for every record where field1 is like 'xx%'  then copy contents of field3 into field2

Using Microsoft SQL server Management studio query I tried:

UPDATE table1
    SET field2 = tbl2.field3
    FROM table1 tbl2
    WHERE tbl2.recid = recid and tbl2.field1 LIKE 'xx%'

I got an error message:
Msg 208, Level 16, State 1, Line 1
Invalid object name 'REQ_MULTIVALUE'.

Any suggestions appreciated.  

Watch Question
SQL Server DBA & Architect, EE Solution Guide
Awarded 2009
Distinguished Expert 2019
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE