multi insert

Posted on 2006-05-31
Last Modified: 2012-05-05
Have 65 rows of the same email_id (email1) but with different values in admin_id and all GMFlag equal to 1. I need the same duplicate rows set up for email2 and email3.

email_id  admin_id  GMFlag
email1    6                   1
email1    7              1

email1    6                   1
email1    7              1
email2    6              1
email2    7              1
email3    6              1
email3    7              1

Insert into databasename..tablename (email_id, admin_id, GMFlag)
select ('email2', 6, 1)
union all select ('email2', 7, 1)
union all select ('email3', 6, 1)
union all select ('email3', 7, 1)

I'm not sure if the above is correct. How do I acheive this?

Question by:fwsteal
    LVL 75

    Expert Comment

    by:Aneesh Retnakaran
    Insert into databasename..tablename (email_id, admin_id, GMFlag)
    select 'email2', 6, 1
    union all select 'email2', 7, 1
    union all select 'email3', 6, 1
    union all select 'email3', 7, 1
    LVL 34

    Accepted Solution

    INSERT INTO databasename..tablename (email_id, admin_id, GMFlag)
    SELECT 'email2', admin_id, GMFlag
    FROM databasename..tablename
    WHERE email_id = 'email1'

    then run it a second time changing 'email2' to 'email3'

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
    Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
    Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
    Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

    745 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

    13 Experts available now in Live!

    Get 1:1 Help Now