Solved

VB Code that Copy ALL DataBase Structure and Data From SQLServer 2000 DB  To another SQLServer2000 DB

Posted on 2007-12-05
3
154 Views
Last Modified: 2013-12-25
Hi there,
As the title implies I want a VB 6.0 code that copy a SQL Server DB to another SQL Server DB with the whole data in the database including the structure of the tables
0
Comment
Question by:Co0L_DBA
  • 2
3 Comments
 
LVL 38

Expert Comment

by:PaulHews
ID: 20413204
You can use SQLDMO to transfer a database from one server to another.  Scroll down to the Sql Transfer samples

http://www.sqldev.net/sqldmo/SamplesVB6.htm
0
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 500 total points
ID: 20418492

Dim rs As New ADODB.Recordset
Dim cn As New ADODB.Connection
Dim sourcedatabase As String
Dim targetdatabase As String
   
Private Sub Command1_Click()
Set rs = New ADODB.Recordset
rs.Open "select *  FROM INFORMATION_SCHEMA.TABLES", cn, adOpenKeyset, adLockOptimistic
Do Until rs.EOF
sql = "select * into " & targetdatabase & ".dbo." & rs.Fields(2) & " from " & sourcedatabase & ".dbo." & rs.Fields(2)
cn.Execute sql
rs.MoveNext
Loop
End Sub

Private Sub Form_Load()
sourcedatabase = "KR_DB"
targetdatabase = "KR_DB3"
Set cn = CreateObject("ADODB.Connection")
Set m_objRecordset = CreateObject("ADODB.Recordset")
cn.Open "dsn=dss;uid=youruserid;pwd=yourpassword" 'this uses dsn to create connection.
cn.DefaultDatabase = sourcedatabase
End Sub
0
 
LVL 17

Expert Comment

by:Shanmuga Sundaram
ID: 20418498
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VbScript to countdown to New Year's Day 6 65
What are programming codes and how do they work? 7 103
IF ELSE Statement in Excel Macro VBA 16 75
RUNRMTCMD from AS/400 12 69
A short article about problems I had with the new location API and permissions in Marshmallow
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
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…

861 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