Advertisement
Advertisement
| 03.27.2008 at 07:01AM PDT, ID: 23274020 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: |
Imports System
Imports System.Data
Imports System.Math
Imports System.Data.SqlClient
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common
Public Class ScriptMain
Public Sub Main()
' Get Source Data
Dim SourceServerName As String = InputBox("What is your Source's Server", "Source Server?", "")
Dim SourceDbName As String = InputBox("What is your Source's Database", "Source Database?", "")
Dim SourceUser As String = InputBox("What is your Source's Username", "Source Username?", "")
Dim SourcePassword As String = InputBox("What is your Source's Password", "Source Password?", "")
' Get Destination Data
Dim DestServerName As String = InputBox("What is your Destination's Server", "Destination Server?", "")
Dim DestDbName As String = InputBox("What is your Destination's Database", "Destination Database?", SourceDbName)
Dim DestUser As String = InputBox("What is your Destination's Username", "Destination Username?", "")
Dim DestPassword As String = InputBox("What is your Destination's Password", "Destination Password?", "")
Dim SourceServerConn As ServerConnection = New ServerConnection(SourceServerName, SourceUser, SourcePassword)
Dim SourceServer As Server = New Server(SourceServerConn)
Dim SourceDb As Database = SourceServer.Databases(SourceDbName)
Dim DestServerConn As ServerConnection = New ServerConnection(DestServerName, DestUser, DestPassword)
Dim DestServer As Server = New Server(DestServerConn)
Dim DestDb As Database = DestServer.Databases("Master")
'Drop the existing DB
Try
Dim rs As DataSet
Dim qry As String = "IF EXISTS (SELECT name FROM sys.databases WHERE name = N'" + DestDbName + "') " & _
"DROP DATABASE [" + DestDbName + "] "
Catch e As Exception
MsgBox(e.Message)
'Do nothing DB doesn't exist
End Try
'Recreate the target DB
DestDb = New Database(DestServer, DestDbName)
DestDb.Create()
' Create Transfer Object and set basic settings
Dim xfr As Transfer = New Transfer(SourceDb)
xfr.DestinationServer = DestServerName
xfr.DestinationDatabase = DestDbName
xfr.DestinationLogin = DestUser
xfr.DestinationPassword = DestPassword
xfr.DropDestinationObjectsFirst = True
xfr.CopyData = True
xfr.CopyAllObjects = False
xfr.CopyAllDefaults = True
xfr.CopyAllDatabaseTriggers = True
xfr.CopyAllTables = True
xfr.CopyAllUsers = False
xfr.CopyAllViews = True
xfr.CopyAllStoredProcedures = True
xfr.Options.WithDependencies = False
xfr.Options.ContinueScriptingOnError = True
xfr.Options.Indexes = True
xfr.Options.ScriptDrops = True
' Start Transfer
xfr.TransferData()
Dts.TaskResult = Dts.Results.Success
End Sub
End Class
|