If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Microsoft SQL Server > Best practice to update a table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-23-12, 19:19
edpatterson edpatterson is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
Best practice to update a table

I know just enough about databases to have figures out I have out grown my spreadsheets

I would like to know the best way to write one T-SQL query to initially fill at table and subsequently update it.

I am dumping the contents of my DNS server and importing it into a table (time_stamp,host_name,ip_address). My DNS is dynamic so a host could in theory have a different address every day. I am not interested in keeping any kind of history, just the address a host had at the time of the dump.

Would I be better off/faster just to drop the table and rebuild it every time?

Thanks,
Ed
Reply With Quote
  #2 (permalink)  
Old 01-24-12, 08:15
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,280
Quote:
Would I be better off/faster just to drop the table and rebuild it every time?
After you have dropped your table, where would you get the new data from to reload it?

What would be the gain to put your data in a database, but keep it up to date in another system? You might just as well print everything on paper and next throw all the pages away.

I think what you need is
1) a way to do a one time import of your current data from Excel in a MSSQL table
2) have software that will allow you to manage that table (create, delete and update DNS entries) from that time on, so you don't need your Excel spreadsheet any more
3) all processes that now use your excel spreadsheet will have to be adjusted to get their data from MSSQL.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
  #3 (permalink)  
Old 01-24-12, 21:23
edpatterson edpatterson is offline
Registered User
 
Join Date: Jan 2012
Posts: 2
I am pushing out application(s) the steps are
extracting the current data from DNS
putting the info into a database
querying out the host names with an IP address beginning with 10.
checking to see if the machine already has the application (logging table)
if not checking to see if the machine is online
pushing out an application to it
logging the push to the logging table

The logging table is of course maintained
The DNS table is really only good for the current run as the addresses are dynamic

So I guess the question would be is it more efficient for me do some kind up update on the DNS table or simply truncate|drop it and re-create|populate it.

Thanks!
Reply With Quote
  #4 (permalink)  
Old 01-25-12, 02:09
Wim Wim is offline
Registered User
 
Join Date: Nov 2004
Posts: 1,280
Code:
So I guess the question would be is it more efficient for me do some kind up update on the DNS table or simply truncate|drop it and re-create|populate it.
Maintaining the data will be done outside MSSQL.
You have two options: performing a MERGE of the current DNS data with the MSSQL data or TRUNCATE the MSSQL table and reload it.

Based on your information, I would give the TRUNCATE and repopulate a try. It is the fastest and easiest way.
__________________
With kind regards . . . . . SQL Server 2000/2005/2008/2008 R2 Earned beers: 16
Wim
Beware of bugs in the above code; I have only proved it correct, not tried it. -- Donald Knuth
Grabel's Law: 2 is not equal to 3 -- not even for very large values of 2.
Pat Phelan's Law: 2 very definitely CAN equal 3 -- in at least two programming languages
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On