Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS SQL Inserting Data Best Practices

Posted on 2014-03-07
4
Medium Priority
?
396 Views
Last Modified: 2014-03-07
I'm trying to find some best practices for importing data into a SQL table.  Not just any SQL table, but an existing table that is used in a complex application.

What I mean by complex is that the table may have many constraints or a trigger or some other unforeseen complication.

I tried a few google searches, but I'm just finding results on how to do inserts.

I know that one cannot just blindly start importing data into a system because all kinds of havoc can be done without careful planning and data quality checks.

How does this apply to different databases such as MSSQL, MySQL, DB2 Oracle, etcetera
0
Comment
Question by:Jeff Darling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
Dan Craciun earned 2000 total points
ID: 39912601
Make a (temporary) table(s) with your new data.
Then duplicate your production db into a staging one.

Then use
INSERT into staging_table
    SELECT fields FROM new_table

Open in new window


This will insert data checking for indexes and constraints.

Once you're convinced all is good, replace the production db with the staging one.

HTH,
Dan
0
 
LVL 13

Author Comment

by:Jeff Darling
ID: 39912753
Thanks Dan, thats a great idea.  that way Unit testing can be done.  It also is helpful to have a development environment.

as soon as I posted this, I tried a few more queries in Google and found some good best practices for SQL in general.  I can look at those and extrapolate from there.
0
 
LVL 13

Author Closing Comment

by:Jeff Darling
ID: 39912758
Thanks for the feedback and your patience.
0
 
LVL 35

Expert Comment

by:Dan Craciun
ID: 39912826
Glad I could help!
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

715 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