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

  • Home
  • SEARCH
  • 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 4272274
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:33:20+00:00 2026-05-21T07:33:20+00:00

I am looking for help; Situation is that I have 2 databases which should

  • 0

I am looking for help;
Situation is that I have 2 databases which should be identical in structure with the exception that the NEW prod dbs has ident columns, PK and fk contraints defined. I have to consolidate 4 slightly different dbs in one ‘TempDB’ then copy the data into the ‘NewProddb’.

I have managed a script lto turn off FK checks, and turn on FK checks, so the insert needs to look something like this;

[Script to disable all FK Constraints (nocheck)]

SET IDENTITY_INSERT [NewProdDB].[dbo].[Event] ON; 
INSERT INTO [dbo].[Event] 
(EventID, Name, StartDate, EndDate, PartnerRegStartDate, PartnerRegEndDate, HouseholdRegStartDate, HouseholdRegEndDate, ChannelId, HasTeam, MaxteamMembers) 

(Select 
EventID, Name, StartDate, EndDate, PartnerRegStartDate, PartnerRegEndDate, HouseholdRegStartDate, HouseholdRegEndDate, ChannelId, HasTeam, MaxteamMembers
From TempDB.dbo.Event);

SET IDENTITY_INSERT [NewProdDb].dbo.[Event] OFF; 

[Script to enable all FK Constraints (check)]

What I want to do is to script this in one go rather than writing a script for ALL the tables separately. ALl Data in All Columns is to be copied.

I hope this is clear.

Thanks in Advance.

  • 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-05-21T07:33:21+00:00Added an answer on May 21, 2026 at 7:33 am

    I will try to answer in terms of Oracle db, you can find equivalents in MSSQL.

    There are system tables which store tables & columns information. So your script can do the following

    1. Pass source schema & target schema
    2. Load tables & corresponding columns with a join between ALL_TABLES & ALL_TAB_COLUMNS for the source schema. Loop the results & generate your insert scripts. You can write it to sql file & then execute.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for help setting a new default property value for an inherited control
I am looking for help in determining if the class model that I am
I'm looking for help with my query below. which is never returning anything for
LINQ gurus, I am looking for help to write a query... I have a
This might be too opinionated a question, but looking for help! I have been
I'm in a situation where I came into a new job and I have
I find myself in a situation that someone else must have got stuck in
I have a weird situation happening that I'm not quite understanding. I have a
I'm looking to develop a mobile app which is going to help people find
I have been struggling with a stupid situation. A customer has asked me 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.