Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS SQL Inserting Data Best Practices

Posted on 2014-03-07
4
Medium Priority
?
399 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
  • 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
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.

876 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