• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 175
  • Last Modified:

Sql server stored procedure

Hi,

Can I get some help in writing a stored procedure.  Essentially I have a table 'BarcodeTypes' and I want to update a field called 'NewName' in this table.  I also have another table called cte which has a column with the same name 'NewName'.  There is another column in both these tables called Type which containt the same values in both tables.

So I want to update the 'BarcodeTypes' table with the values from the 'cte' table.

Thanks
0
joygomez
Asked:
joygomez
  • 3
1 Solution
 
Rajkumar GsSoftware EngineerCommented:
update b
set NewName = c.NewName
from BarcodeTypes b
inner join cte c on b.Type = c.Type

Open in new window

0
 
joygomezAuthor Commented:
Thanks... worked great.... appreciate your help
0
 
Rajkumar GsSoftware EngineerCommented:
Or
update BarcodeTypes
set NewName = c.NewName
from cte c where #BarcodeTypes.Type = c.Type

Open in new window

0
 
Rajkumar GsSoftware EngineerCommented:
Glad to help you
Raj
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now