[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Overwrite SQL table

Posted on 2010-09-09
7
Medium Priority
?
597 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
[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
  • 2
  • +1
7 Comments
 
LVL 143

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 750 total points
ID: 33636339
delete from table;
insert into table select column1, column2 from newTable;
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 143

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Introduction: When running hybrid database environments, you often need to query some data from a remote db of any type, while being connected to your MS SQL Server database. Problems start when you try to combine that with some "user input" pass…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 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