Solved

Overwrite SQL table

Posted on 2010-09-09
7
581 Views
Last Modified: 2012-05-10
Hello,

I'm new to the SQL world.  I have a table in a SQL database with 2 columns containing about 4000 records, which needs to be overwritten with a new set of 4000 records.  How can i easily achieve this?
0
Comment
Question by:PLA_LTM
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33636302
where does the data come from?
0
 

Author Comment

by:PLA_LTM
ID: 33636331
I have an excel sheet that currently has this info.

Ideally, is there a way to have my SQL table merely reference this excel sheet??  So that, in the future, if we make changes the table will update automatically?

0
 
LVL 1

Accepted Solution

by:
movendra earned 250 total points
ID: 33636339
delete from table;
insert into table select column1, column2 from newTable;
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 57

Expert Comment

by:Raja Jegan R
ID: 33636370
Yes, Just create that Excel file as a linked server in SQL Server.
Once done, all changes done in the Excel sheet can be directly references from SQL Server as a table or view as required.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33636386
>Ideally, is there a way to have my SQL table merely reference this excel sheet??

actually, ideally would be to have the sql table be the reference, and the excel sheet update from the sql table? after all, sql is the database system, not excel ... no?

apart from that... with SSIS, you can import/export from/to table<--->excel ...
please check that out
0
 
LVL 1

Expert Comment

by:movendra
ID: 33636438
NO, you can't "link" a SQL table to an excel datasheet. If you need to automate import you'll better save data in a text file ( CSV ) and then import with a BULK INSERT statement. Excel is not a good choice for a data source. I always had many problems with it. What kind of data do you have to import ? ( string, numeric, datetime, .... )
0
 

Author Closing Comment

by:PLA_LTM
ID: 33640414
Thanks for the advise.  I ended up deleting the table and adding a new.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now