I have a task that I need to copy A data from 1 table on 1 database into
another table on another database . the tables are identical. I wrote
some script But Can Anyone check the script
'**********************************************************************
' Visual Basic Transformation Script
'************************************************************************
' Copy each source column to the destination column
Function Main()
dim var
Dim cn '* As New ADODB Connection
Dim cn2 '* As New ADODB Connection
Dim strConn
Dim strConn2
Dim strSQL
var=InputBox ("Please specify the site Id that you would like to transform")
while var <> 8
var=INputBox ("Please enter the correct CompanyID" )
wend
Set cn= CreateObject("ADODB.Connection")
' Connection to SQL Server without using ODBC data source
strConn = "Driver={SQL Server};Server=" &
DTSGlobalVariables("gvSServer").Value & ";Uid=ErikDBO;Pwd=" &
DTSGlobalVariables("gvSPwd").Value & ";Database=" &
DTSGlobalVariables("gvDDB").Value
cn.Open strConn
set rs = nothing
strSQL ="Insert Into tblCompany (txtTitle) Values ("
&DTSSource("txtTitle") &") "
Set rs = CreateObject("ADODB.RecordSet")
Set rs = cn.Execute(strSQL)
if rs.BOF or rs.EOF then
msgBox "No record was inserted"
esle DTSDestination("txtTitle")=DTSSource("txtTitle").Value
end if
set rs = nothing
cn.close
set cn = nothing
End Function
MS Sql Server LazyDBA home page