This is a mirror of official site: http://jasper-net.blogspot.com/

SQL Tips: MS SQL Copy Table with Data and Structure

| Sunday, October 24, 2010
3.gif

Introduction

This article series is about the various SQL tips/techniques that I came across in my professional work. It will be very silly to someone who is an expert in SQL Server. But this article discusses some of the tips/techniques that I encountered when I tried to solve problems in SQL in my day-to-day programming life. I will be updating this series whenever I come across various problems which may not be easily accessible in the internet or you may not find the result in google search!

Copying Table to New Table

In our very first tip we will discuss creating a replica of a table in SQL with data and constraint/keys. Often we come across situation in which we may be working on enhancements/technical bugs/improvements in our products which may need to alter/change table data/table structures. Apart from us, many other developers may be working on the same table. Sometimes, we may do trial and error of changing the table data/structure. We may wish that other developers are not affected with the changes. We can copy the content/structure of the table to a new one and experiment in the new table, do whatever changes we want and finally make change to the original table.

A Brief Example

We have a table named as EmployeeDetails and EmployeeDesignation. The content of the tables are as shown below.

Read more: C# Corner

Posted via email from .NET Info

0 comments: