Solved

VB.net Duplicate a SQL table

Posted on 2013-10-28
2
304 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
2 Comments
 
LVL 6

Accepted Solution

by:
ButlerTechnology earned 500 total points
Comment Utility
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
Comment Utility
Thanks very much
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
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.

771 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

12 Experts available now in Live!

Get 1:1 Help Now