Sql server stored procedure

Posted on 2011-10-19
Last Modified: 2012-05-12

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.

Question by:joygomez
    LVL 23

    Accepted Solution

    update b
    set NewName = c.NewName
    from BarcodeTypes b
    inner join cte c on b.Type = c.Type

    Open in new window


    Author Closing Comment

    Thanks... worked great.... appreciate your help
    LVL 23

    Expert Comment

    by:Rajkumar Gs
    update BarcodeTypes
    set NewName = c.NewName
    from cte c where #BarcodeTypes.Type = c.Type

    Open in new window

    LVL 23

    Expert Comment

    by:Rajkumar Gs
    Glad to help you

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
    In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now