select into Dest.TbName from Source.TbName没试过,我也不知道行不行,99%不行

解决方案 »

  1.   

    我这里到查到一些,但是使用的时候报了错,不知道怎么回事
    这些是标准的SQL导出语句:
    select * into [Excel 8.0;database=导出目录].导出表名 from 表
    select * into [FoxPro 2.6;database=导出目录].导出表名 from 表
    select * into [FoxPro 2.5;database=同上].导出表名 from 表
    select * into [dBase III;database=同上].导出表名 from 表
    select * into [Paradox 4.X;database=同上].导出表名 from 表
    select * into [;database=C:\temp\xxx.mdb].导出表名 from 表
    我用的最后一句,报的错是报错:[specified owner name 'Access 8.0;database=g:\Inetpub\wwwroot\db3.mdb' either does not exist or you do not have permission to use it]
    该数据库存在,而且我已经把EVERYONE的访问权限都设成最高了呀!! 
      

  2.   

    是不是需要程序解决问题的?
    不需要的话直接可以用SQL SERVER的企业管理器中的任务-〉导出数据解决
      

  3.   

    最笨的就是打开两个ADO连接,一个SQL SERVER一个Access(or...)
    自己一个一个加
      

  4.   

    在SQL Server使用它的Import/Export工具即可,它的使用很简单,根向导一步一步作就可以了
      

  5.   

    你程序有时间要求没有,如果没有,干脆自己去写一个程序算了,我的程序就是因为有时间要求,若自己写的就比较慢。微软就是这样的东西,将一些关键的内容藏起来不让人知道,要是知道SQL数据的存放格式就好了!
      

  6.   

    to xiaoheng():select * into [dBase III;database=导出目录].导出表名 from 表 这语句行不行呀,我怎么在我的机器上怎么也调试不过去?所报错误同你的相似。若你机器上能通过,望写全语句,比如"导出目录"可以随便用一具体目录代替等。
      

  7.   

    '****************************************************************
    'Microsoft SQL Server 2000
    'Visual Basic file generated for DTS Package
    'File Name: D:\SQL2Access.bas
    'Package Name: SQL2Access
    'Package Description: Transfer table and data from sql server to access
    'Generated Date: 2001-9-5
    'Generated Time: 12:40:04
    '****************************************************************Option Explicit
    Public goPackageOld As New DTS.Package
    Public goPackage As DTS.Package2
    Private Sub Main()
    set goPackage = goPackageOld goPackage.Name = "SQL2Access"
    goPackage.Description = "Transfer table and data from sql server to access"
    goPackage.WriteCompletionStatusToNTEventLog = False
    goPackage.FailOnError = False
    goPackage.PackagePriorityClass = 2
    goPackage.MaxConcurrentSteps = 4
    goPackage.LineageOptions = 0
    goPackage.UseTransaction = True
    goPackage.TransactionIsolationLevel = 4096
    goPackage.AutoCommitTransaction = True
    goPackage.RepositoryMetadataOptions = 0
    goPackage.UseOLEDBServiceComponents = True
    goPackage.LogToSQLServer = False
    goPackage.LogServerFlags = 0
    goPackage.FailPackageOnLogFailure = False
    goPackage.ExplicitGlobalVariables = False
    goPackage.PackageType = 0
    Dim oConnProperty As DTS.OleDBProperty'---------------------------------------------------------------------------
    ' create package connection information
    '---------------------------------------------------------------------------Dim oConnection as DTS.Connection2'------------- a new connection defined below.
    'For security purposes, the password is never scriptedSet oConnection = goPackage.Connections.New("SQLOLEDB") oConnection.ConnectionProperties("Persist Security Info") = True
    oConnection.ConnectionProperties("User ID") = "sa"
    oConnection.ConnectionProperties("Initial Catalog") = "Printer"
    oConnection.ConnectionProperties("Data Source") = "KENFILSZNT"
    oConnection.ConnectionProperties("Application Name") = "DTS 导入/导出向导"

    oConnection.Name = "连接1"
    oConnection.ID = 1
    oConnection.Reusable = True
    oConnection.ConnectImmediate = False
    oConnection.DataSource = "KENFILSZNT"
    oConnection.UserID = "sa"
    oConnection.ConnectionTimeout = 60
    oConnection.Catalog = "Printer"
    oConnection.UseTrustedConnection = False
    oConnection.UseDSL = False

    'If you have a password for this connection, please uncomment and add your password below.
    'oConnection.Password = "<put the password here>"goPackage.Connections.Add oConnection
    Set oConnection = Nothing'------------- a new connection defined below.
    'For security purposes, the password is never scriptedSet oConnection = goPackage.Connections.New("Microsoft.Jet.OLEDB.4.0") oConnection.ConnectionProperties("User ID") = "Admin"
    oConnection.ConnectionProperties("Data Source") = "D:\1.mdb"
    oConnection.ConnectionProperties("Mode") = 3

    oConnection.Name = "连接2"
    oConnection.ID = 2
    oConnection.Reusable = True
    oConnection.ConnectImmediate = False
    oConnection.DataSource = "D:\1.mdb"
    oConnection.UserID = "Admin"
    oConnection.ConnectionTimeout = 60
    oConnection.UseTrustedConnection = False
    oConnection.UseDSL = False

    'If you have a password for this connection, please uncomment and add your password below.
    'oConnection.Password = "<put the password here>"goPackage.Connections.Add oConnection
    Set oConnection = Nothing'---------------------------------------------------------------------------
    ' create package steps information
    '---------------------------------------------------------------------------Dim oStep as DTS.Step2
    Dim oPrecConstraint as DTS.PrecedenceConstraint'------------- a new step defined belowSet oStep = goPackage.Steps.New oStep.Name = "创建表 master 步骤"
    oStep.Description = "创建表 master 步骤"
    oStep.ExecutionStatus = 1
    oStep.TaskName = "创建表 master 任务"
    oStep.CommitSuccess = False
    oStep.RollbackFailure = False
    oStep.ScriptLanguage = "VBScript"
    oStep.AddGlobalVariables = True
    oStep.RelativePriority = 3
    oStep.CloseConnection = False
    oStep.ExecuteInMainThread = False
    oStep.IsPackageDSORowset = False
    oStep.JoinTransactionIfPresent = False
    oStep.DisableStep = False
    oStep.FailPackageOnError = False

    goPackage.Steps.Add oStep
    Set oStep = Nothing'------------- a new step defined belowSet oStep = goPackage.Steps.New oStep.Name = "Copy Data from master to master 步骤"
    oStep.Description = "Copy Data from master to master 步骤"
    oStep.ExecutionStatus = 1
    oStep.TaskName = "Copy Data from master to master 任务"
    oStep.CommitSuccess = False
    oStep.RollbackFailure = False
    oStep.ScriptLanguage = "VBScript"
    oStep.AddGlobalVariables = True
    oStep.RelativePriority = 3
    oStep.CloseConnection = False
    oStep.ExecuteInMainThread = True
    oStep.IsPackageDSORowset = False
    oStep.JoinTransactionIfPresent = False
    oStep.DisableStep = False
    oStep.FailPackageOnError = False

    goPackage.Steps.Add oStep
    Set oStep = Nothing'------------- a precedence constraint for steps defined belowSet oStep = goPackage.Steps("Copy Data from master to master 步骤")
    Set oPrecConstraint = oStep.PrecedenceConstraints.New("创建表 master 步骤")
    oPrecConstraint.StepName = "创建表 master 步骤"
    oPrecConstraint.PrecedenceBasis = 0
    oPrecConstraint.Value = 4

    oStep.precedenceConstraints.Add oPrecConstraint
    Set oPrecConstraint = Nothing'---------------------------------------------------------------------------
    ' create package tasks information
    '---------------------------------------------------------------------------'------------- call Task_Sub1 for task 创建表 master 任务 (创建表 master 任务)
    Call Task_Sub1( goPackage )'------------- call Task_Sub2 for task Copy Data from master to master 任务 (Copy Data from master to master 任务)
    Call Task_Sub2( goPackage )'---------------------------------------------------------------------------
    ' Save or execute package
    '---------------------------------------------------------------------------'goPackage.SaveToSQLServer "(local)", "sa", ""
    goPackage.Execute
    goPackage.Uninitialize
    'to save a package instead of executing it, comment out the executing package line above and uncomment the saving package line
    set goPackage = Nothingset goPackageOld = NothingEnd Sub
    '------------- define Task_Sub1 for task 创建表 master 任务 (创建表 master 任务)
    Public Sub Task_Sub1(ByVal goPackage As Object)Dim oTask As DTS.Task
    Dim oLookup As DTS.LookupDim oCustomTask1 As DTS.ExecuteSQLTask2
    Set oTask = goPackage.Tasks.New("DTSExecuteSQLTask")
    Set oCustomTask1 = oTask.CustomTask oCustomTask1.Name = "创建表 master 任务"
    oCustomTask1.Description = "创建表 master 任务"
    oCustomTask1.SQLStatement = "CREATE TABLE `master` (" & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`JobID` Long NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`LoginID` VarChar (50) NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`CreateDateTime` DateTime NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`ReportID` Long NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`Priority` Long NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`StartDateTime` DateTime NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`EndDateTime` DateTime NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`Counter` Long NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`Status` Long NOT NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`FileURLPath` LongText NULL, " & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & "`FilePhyPath` LongText NULL" & vbCrLf
    oCustomTask1.SQLStatement = oCustomTask1.SQLStatement & ")"
    oCustomTask1.ConnectionID = 2
    oCustomTask1.CommandTimeout = 0
    oCustomTask1.OutputAsRecordset = False

    goPackage.Tasks.Add oTask
    Set oCustomTask1 = Nothing
    Set oTask = NothingEnd Sub'------------- define Task_Sub2 for task Copy Data from master to master 任务 (Copy Data from master to master 任务)
    Public Sub Task_Sub2(ByVal goPackage As Object)Dim oTask As DTS.Task
    Dim oLookup As DTS.LookupDim oCustomTask2 As DTS.DataPumpTask2
    Set oTask = goPackage.Tasks.New("DTSDataPumpTask")
    Set oCustomTask2 = oTask.CustomTask oCustomTask2.Name = "Copy Data from master to master 任务"
    oCustomTask2.Description = "Copy Data from master to master 任务"
    oCustomTask2.SourceConnectionID = 1
    oCustomTask2.SourceSQLStatement = "select [JobID],[LoginID],[CreateDateTime],[ReportID],[Priority],[StartDateTime],[EndDateTime],[Counter],[Status],[FileURLPath],[FilePhyPath] from [Printer].[dbo].[master]"
    oCustomTask2.DestinationConnectionID = 2
    oCustomTask2.DestinationObjectName = "master"
    oCustomTask2.ProgressRowCount = 1000
    oCustomTask2.MaximumErrorCount = 0
    oCustomTask2.FetchBufferSize = 1
    oCustomTask2.UseFastLoad = True
    oCustomTask2.InsertCommitSize = 0
    oCustomTask2.ExceptionFileColumnDelimiter = "|"
    oCustomTask2.ExceptionFileRowDelimiter = vbCrLf
    oCustomTask2.AllowIdentityInserts = False
    oCustomTask2.FirstRow = 0
    oCustomTask2.LastRow = 0
    oCustomTask2.FastLoadOptions = 2
    oCustomTask2.ExceptionFileOptions = 1
    oCustomTask2.DataPumpOptions = 0

    Call oCustomTask2_Trans_Sub1( oCustomTask2 )


    goPackage.Tasks.Add oTask
    Set oCustomTask2 = Nothing
    Set oTask = NothingEnd SubPublic Sub oCustomTask2_Trans_Sub1(ByVal oCustomTask2 As Object) Dim oTransformation As DTS.Transformation2
    Dim oTransProps as DTS.Properties
    Dim oColumn As DTS.Column
    Set oTransformation = oCustomTask2.Transformations.New("DTS.DataPumpTransformCopy")
    oTransformation.Name = "DirectCopyXform"
    oTransformation.TransformFlags = 63
    oTransformation.ForceSourceBlobsBuffered = 0
    oTransformation.ForceBlobsInMemory = False
    oTransformation.InMemoryBlobSize = 1048576
    oTransformation.TransformPhases = 4

    Set oColumn = oTransformation.SourceColumns.New("JobID" , 1)
    oColumn.Name = "JobID"
    oColumn.Ordinal = 1
    oColumn.Flags = 16
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("LoginID" , 2)
    oColumn.Name = "LoginID"
    oColumn.Ordinal = 2
    oColumn.Flags = 8
    oColumn.Size = 50
    oColumn.DataType = 130
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("CreateDateTime" , 3)
    oColumn.Name = "CreateDateTime"
    oColumn.Ordinal = 3
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 135
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("ReportID" , 4)
    oColumn.Name = "ReportID"
    oColumn.Ordinal = 4
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("Priority" , 5)
    oColumn.Name = "Priority"
    oColumn.Ordinal = 5
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("StartDateTime" , 6)
    oColumn.Name = "StartDateTime"
    oColumn.Ordinal = 6
    oColumn.Flags = 120
    oColumn.Size = 0
    oColumn.DataType = 135
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("EndDateTime" , 7)
    oColumn.Name = "EndDateTime"
    oColumn.Ordinal = 7
    oColumn.Flags = 120
    oColumn.Size = 0
    oColumn.DataType = 135
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("Counter" , 8)
    oColumn.Name = "Counter"
    oColumn.Ordinal = 8
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("Status" , 9)
    oColumn.Name = "Status"
    oColumn.Ordinal = 9
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("FileURLPath" , 10)
    oColumn.Name = "FileURLPath"
    oColumn.Ordinal = 10
    oColumn.Flags = 104
    oColumn.Size = 1024
    oColumn.DataType = 130
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.SourceColumns.New("FilePhyPath" , 11)
    oColumn.Name = "FilePhyPath"
    oColumn.Ordinal = 11
    oColumn.Flags = 104
    oColumn.Size = 1024
    oColumn.DataType = 130
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.SourceColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("JobID" , 1)
    oColumn.Name = "JobID"
    oColumn.Ordinal = 1
    oColumn.Flags = 16
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("LoginID" , 2)
    oColumn.Name = "LoginID"
    oColumn.Ordinal = 2
    oColumn.Flags = 8
    oColumn.Size = 50
    oColumn.DataType = 130
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("CreateDateTime" , 3)
    oColumn.Name = "CreateDateTime"
    oColumn.Ordinal = 3
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 7
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("ReportID" , 4)
    oColumn.Name = "ReportID"
    oColumn.Ordinal = 4
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("Priority" , 5)
    oColumn.Name = "Priority"
    oColumn.Ordinal = 5
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("StartDateTime" , 6)
    oColumn.Name = "StartDateTime"
    oColumn.Ordinal = 6
    oColumn.Flags = 120
    oColumn.Size = 0
    oColumn.DataType = 7
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("EndDateTime" , 7)
    oColumn.Name = "EndDateTime"
    oColumn.Ordinal = 7
    oColumn.Flags = 120
    oColumn.Size = 0
    oColumn.DataType = 7
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("Counter" , 8)
    oColumn.Name = "Counter"
    oColumn.Ordinal = 8
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("Status" , 9)
    oColumn.Name = "Status"
    oColumn.Ordinal = 9
    oColumn.Flags = 24
    oColumn.Size = 0
    oColumn.DataType = 3
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = False

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("FileURLPath" , 10)
    oColumn.Name = "FileURLPath"
    oColumn.Ordinal = 10
    oColumn.Flags = 104
    oColumn.Size = 0
    oColumn.DataType = 130
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oColumn = oTransformation.DestinationColumns.New("FilePhyPath" , 11)
    oColumn.Name = "FilePhyPath"
    oColumn.Ordinal = 11
    oColumn.Flags = 104
    oColumn.Size = 0
    oColumn.DataType = 130
    oColumn.Precision = 0
    oColumn.NumericScale = 0
    oColumn.Nullable = True

    oTransformation.DestinationColumns.Add oColumn
    Set oColumn = Nothing Set oTransProps = oTransformation.TransformServerProperties
    Set oTransProps = Nothing oCustomTask2.Transformations.Add oTransformation
    Set oTransformation = NothingEnd Sub