Solved

VB.net Duplicate a SQL table

Posted on 2013-10-28
2
310 Views
Last Modified: 2013-10-28
Hi

What VB.net code would I use to duplicate an SQL table using
SQL Client style of coding similar to the following:

            Dim myConnection As SqlConnection = New SqlConnection(Globals.ThisAddIn.oRIGHT.lblConnectionString.Text)
            Dim myCommand As SqlCommand

            Dim ra As Integer

            Dim sSQL As String = "ALTER TABLE [" & oTable & "] DROP COLUMN [" & oColumn & "]"


            myConnection.Open()

            myCommand = New SqlCommand(sSQL, myConnection)
            ra = myCommand.ExecuteNonQuery()

            DropColumnSQL = True

            myConnection.Close()
0
Comment
Question by:murbro
[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 Comments
 
LVL 6

Accepted Solution

by:
ButlerTechnology earned 500 total points
ID: 39605305
The following TSQL will duplicate a table structure without putting any data in it.
Select *
into EmployeeCopy
from Employee
where empID = 0

Open in new window

This does only the basic structure.  It will not duplicate the primary key constraint.

Tom
0
 

Author Closing Comment

by:murbro
ID: 39605311
Thanks very much
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

751 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