Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
dpnash
Starting Member
1 Post |
Posted - 2009-06-17 : 17:24:07
|
Good afternoon,I'm working on an old (classic ASP) application that needs to process SQL Server 7 or MSDE 1.0 databases and copy portions of them to a remote server running SQL Server 2000. I am having trouble getting DTS to actually copy the data. It seems to create the target table just fine, but then fails on the table-copying step.I've used the Visual Basic packages that the DTS wizard creates as a basis for an ASP (VBScript) page to do the transfer. The DTS packages run perfectly. To isolate the problem I've tried to do simpler tasks than the full app at first. Here's a sample VBScript subroutine that is supposed to copy a single small table from one database to another on the same server (login information removed). This particular DTS package attempts to copy between two SQL Server 7 databases, but I have similar problems when copying data to SQL Server 2000:---Public Sub TestDataLoader()Dim goPackageSet goPackage = Server.CreateObject("DTS.Package2")goPackage.Name = "AETest to AETest_Import"goPackage.Description = "Test intra-DB copy"goPackage.WriteCompletionStatusToNTEventLog = FalsegoPackage.FailOnError = True ' was FalsegoPackage.PackagePriorityClass = 2goPackage.MaxConcurrentSteps = 4goPackage.LineageOptions = 0goPackage.UseTransaction = TruegoPackage.TransactionIsolationLevel = 4096goPackage.AutoCommitTransaction = TruegoPackage.RepositoryMetadataOptions = 0goPackage.UseOLEDBServiceComponents = TrueDim oConnPropertyDim oConnectionSet oConnection = goPackage.Connections.New("SQLOLEDB.1")oConnection.ConnectionProperties("Persist Security Info").Value = TrueoConnection.ConnectionProperties("User ID").Value = "xxx"oConnection.ConnectionProperties("Initial Catalog").Value = "aetest"oConnection.ConnectionProperties("Data Source").Value = "xxx"oConnection.Name = "Connection 1"oConnection.ID = 1oConnection.Reusable = TrueoConnection.ConnectImmediate = FalseoConnection.DataSource = "xxx"oConnection.UserID = "xxx"oConnection.ConnectionTimeout = 60oConnection.Catalog = "aetest"oConnection.UseTrustedConnection = FalseoConnection.UseDSL = FalsegoPackage.Connections.Add oConnectionSet oConnection = NothingSet oConnection = goPackage.Connections.New("SQLOLEDB.1")oConnection.ConnectionProperties("Persist Security Info").Value = TrueoConnection.ConnectionProperties("User ID").Value = "xxx"oConnection.ConnectionProperties("Initial Catalog").Value = "aetest_import"oConnection.ConnectionProperties("Data Source").Value = "xxx"oConnection.Name = "Connection 2"oConnection.ID = 2oConnection.Reusable = TrueoConnection.ConnectImmediate = FalseoConnection.DataSource = "xxx"oConnection.UserID = "xxx"oConnection.ConnectionTimeout = 60oConnection.Catalog = "aetest_import"oConnection.UseTrustedConnection = FalseoConnection.UseDSL = FalsegoPackage.Connections.Add oConnectionSet oConnection = NothingDim oStep 'As DTS.Step2Dim oPrecConstraint 'as DTS.PrecedenceConstraintSet oStep = goPackage.Steps.NewoStep.Name = "Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Step"oStep.Description = "Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Step"oStep.ExecutionStatus = 1oStep.TaskName = "Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Task"oStep.CommitSuccess = FalseoStep.RollbackFailure = FalseoStep.ScriptLanguage = "VBScript"oStep.AddGlobalVariables = TrueoStep.RelativePriority = 3oStep.CloseConnection = FalseoStep.ExecuteInMainThread = FalseoStep.IsPackageDSORowset = FalseoStep.JoinTransactionIfPresent = FalseoStep.DisableStep = FalsegoPackage.Steps.Add oStepSet oStep = NothingSet oStep = goPackage.Steps.NewoStep.Name = "Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Step"oStep.Description = "Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Step"oStep.ExecutionStatus = 1oStep.TaskName = "Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Task"oStep.CommitSuccess = FalseoStep.RollbackFailure = FalseoStep.ScriptLanguage = "VBScript"oStep.AddGlobalVariables = TrueoStep.RelativePriority = 3oStep.CloseConnection = FalseoStep.ExecuteInMainThread = FalseoStep.IsPackageDSORowset = FalseoStep.JoinTransactionIfPresent = FalseoStep.DisableStep = FalsegoPackage.Steps.Add oStepSet oStep = NothingSet oStep = goPackage.Steps("Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Step")Set oPrecConstraint = oStep.PrecedenceConstraints.New("Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Step")oPrecConstraint.StepName = "Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Step"oPrecConstraint.PrecedenceBasis = 0oPrecConstraint.Value = 4oStep.precedenceConstraints.Add oPrecConstraintSet oPrecConstraint = NothingCall Task_Sub1( goPackage )Call Task_Sub2( goPackage )goPackage.ExecutegoPackage.Uninitializeset goPackage = NothingEnd SubPublic Sub Task_Sub1(ByVal goPackage)Dim oTaskDim oLookupDim oCustomTask1Set oTask = goPackage.Tasks.New("DTSExecuteSQLTask")Set oCustomTask1 = oTask.CustomTaskoCustomTask1.Name = "Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Task"oCustomTask1.Description = "Create Table [aetest_import].[dbo].[ACCOUNTCODE_REF] Task"oCustomTask1.SQLStatement = "CREATE TABLE [aetest_import].[dbo].[ACCOUNTCODE_REF] (" & vbCrLfoCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "[AC_ID] smallint NOT NULL, " & vbCrLfoCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "[AC_CODE] varchar (20) NOT NULL" & vbCrLfoCustomTask1.SQLStatement = oCustomTask1.SQLStatement & ")"oCustomTask1.ConnectionID = 2oCustomTask1.CommandTimeout = 0goPackage.Tasks.Add oTaskSet oCustomTask1 = NothingSet oTask = NothingEnd SubPublic Sub Task_Sub2(ByVal goPackage)Dim oTaskDim oLookupDim oCustomTask2Set oTask = goPackage.Tasks.New("DTSDataPumpTask")Set oCustomTask2 = oTask.CustomTaskoCustomTask2.Name = "Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Task"oCustomTask2.Description = "Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Task"oCustomTask2.SourceConnectionID = 1oCustomTask2.SourceSQLStatement = "select [AC_ID],[AC_CODE] from [aetest].[dbo].[ACCOUNTCODE_REF]"oCustomTask2.DestinationConnectionID = 2oCustomTask2.DestinationObjectName = "[aetest_import].[dbo].[ACCOUNTCODE_REF]"oCustomTask2.ProgressRowCount = 1000oCustomTask2.MaximumErrorCount = 0oCustomTask2.FetchBufferSize = 1oCustomTask2.UseFastLoad = TrueoCustomTask2.InsertCommitSize = 0oCustomTask2.ExceptionFileColumnDelimiter = "|"oCustomTask2.ExceptionFileRowDelimiter = vbCrLfoCustomTask2.AllowIdentityInserts = FalseoCustomTask2.FastLoadOptions = 2Call oCustomTask2_Trans_Sub1( oCustomTask2 )goPackage.Tasks.Add oTaskSet oCustomTask2 = NothingSet oTask = NothingEnd SubPublic Sub oCustomTask2_Trans_Sub1(ByVal oCustomTask2)Dim oTransformationDim oTransPropsDim oColumnSet oTransformation = oCustomTask2.Transformations.New("DTS.DataPumpTransformCopy")oTransformation.Name = "DirectCopyXform"oTransformation.TransformFlags = 63oTransformation.ForceSourceBlobsBuffered = 0oTransformation.ForceBlobsInMemory = FalseoTransformation.InMemoryBlobSize = 1048576Set oColumn = oTransformation.SourceColumns.New("AC_ID" , 1)oColumn.Name = "AC_ID"oColumn.Ordinal = 1oColumn.Flags = 24oColumn.Size = 0oColumn.DataType = 2oColumn.Precision = 0oColumn.NumericScale = 0oColumn.Nullable = FalseoTransformation.SourceColumns.Add oColumnSet oColumn = NothingSet oColumn = oTransformation.SourceColumns.New("AC_CODE" , 2)oColumn.Name = "AC_CODE"oColumn.Ordinal = 2oColumn.Flags = 8oColumn.Size = 20oColumn.DataType = 129oColumn.Precision = 0oColumn.NumericScale = 0oColumn.Nullable = FalseoTransformation.SourceColumns.Add oColumnSet oColumn = NothingSet oColumn = oTransformation.DestinationColumns.New("AC_ID" , 1)oColumn.Name = "AC_ID"oColumn.Ordinal = 1oColumn.Flags = 24oColumn.Size = 0oColumn.DataType = 2oColumn.Precision = 0oColumn.NumericScale = 0oColumn.Nullable = FalseoTransformation.DestinationColumns.Add oColumnSet oColumn = NothingSet oColumn = oTransformation.DestinationColumns.New("AC_CODE" , 2)oColumn.Name = "AC_CODE"oColumn.Ordinal = 2oColumn.Flags = 8oColumn.Size = 20oColumn.DataType = 129oColumn.Precision = 0oColumn.NumericScale = 0oColumn.Nullable = FalseoTransformation.DestinationColumns.Add oColumnSet oColumn = NothingoCustomTask2.Transformations.Add oTransformationSet oTransformation = NothingEnd Sub---As I mentioned above, the original DTS package to do this task works perfectly fine. However, the ASP page running this minimally-modified code fails at the copying step:Microsoft Data Transformation Services (DTS) Package error '80040428'Package failed because Step 'Copy Data from ACCOUNTCODE_REF to [aetest_import].[dbo].[ACCOUNTCODE_REF] Step' failed./AE6/includes/MiniDataLoaderOneDB.asp, line 109-- I can log into the database and confirm there is a new table with the correct column definitions, but it has 0 rows.I haven't been able to use GetExecutionErrorInfo to extract error code info; the script either fails to recognize it as a valid method of the DTS step object, or returns blank values for all the possible values it can return.If anyone could give me any concrete suggestions for what might be going on here, or even to suggest an improved method for moving the data around, I'd appreciate it enormously.Sincerely,David Nash, Sr. Developer, Avotus |
|
|
|
|
|
|