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

x
?
Solved

Make a backup of a SQL Server table

Posted on 2013-12-02
5
Medium Priority
?
304 Views
Last Modified: 2013-12-02
I created a backup table named StockHistBak by copying the structure of StockHist.

How to I populate StockHistBak from the data in StockHist?

Thanks,
0
Comment
Question by:Dovberman
[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
  • 3
5 Comments
 
LVL 25

Accepted Solution

by:
Lee Savidge earned 1600 total points
ID: 39689570
If it's a one off, drop it and do this:

select * into StockHistBak from StockHist

If it's something you want do do regularly, create a maintenance task to drop and recreate it sing the above code.
0
 
LVL 25

Assisted Solution

by:Lee Savidge
Lee Savidge earned 1600 total points
ID: 39689572
If you don't want to drop the table, then use something like this:

insert into StockHistBak
select * from StockHist
0
 
LVL 57

Assisted Solution

by:Raja Jegan R
Raja Jegan R earned 400 total points
ID: 39689573
via TSQL:

INSERT INTO StockHistBak
SELECT * FROM StockHist

If you have Identity column on the table then you have to use SET IDENTITY_INSERT StockHist ON and Off before and after the statements along with column list instead of * to get it work.
0
 

Author Closing Comment

by:Dovberman
ID: 39689651
Thank you all.
0
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39689667
You're welcome.
0

Featured Post

What Is Blockchain Technology?

Blockchain is a technology that underpins the success of Bitcoin and other digital currencies, but it has uses far beyond finance. Learn how blockchain works and why it is proving disruptive to other areas of IT.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

670 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