Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8312415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T20:09:24+00:00 2026-06-08T20:09:24+00:00

I have a number of records that I need to insert into multiple tables.

  • 0

I have a number of records that I need to insert into multiple tables. Every other column will be a constant.

Poor pseudo code below – this is what I want to do:

create table #temp_buildings
(
    building_id varchar(20)
)
insert into #temp_buildings (building_id) VALUES ('11070')
insert into #temp_buildings (building_id) VALUES ('11071')
insert into #temp_buildings (building_id) VALUES ('20570')
insert into #temp_buildings (building_id) VALUES ('21570')
insert into #temp_buildings (building_id) VALUES ('22570')

insert into property.portfolio_property_xref
        ( portfolio_id ,
          building_id ,
          created_date ,
          last_modified_date
        )
values
        ( 
            34 ,
            (
                select  building_id
                from    #temp_buildings
            ) ,
            getdate() ,
            null
        )

Intent: Perform an insert into property.portfolio_property_xref for each record on #temp_buildings

I think I could do this with a cursor – but believe this would be horribly slow. As this exercise will be repeatable in future I’d rather tackle this in a faster method but I’m unsure how. Any feedback would be appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T20:09:25+00:00Added an answer on June 8, 2026 at 8:09 pm
    INSERT INTO table1 ( column1 )
    SELECT  col1
    FROM    table2
    

    Like:

    insert into property.portfolio_property_xref
    ( 
        portfolio_id ,
        building_id ,
        created_date ,
        last_modified_date
    )
    select
        34,
        building_id,
        getdate(),
        null
    from
        #temp_buildings
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to insert multiple records into a table. The number of records depend
I have 1-many number of records that need to be entered into a table.
I have a large number of records (10,000, increasing every day) that essentially is
I have a database with a large number of records that are Date/Time stamped.
I'm trying to count the number of records that have a null DateTime value.
I have this query that, due to the number of records, is taking several
I have a jqGrid with which users will select records. A large number of
I have X number of image objects that I need to loop through in
Ok so I have a text file that will change regularly that I need
I have a large number of records, say around 4,000,000, that I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.