about sql |
尚未結案
|
yx_huang77
一般會員 ![]() ![]() 發表:46 回覆:64 積分:22 註冊:2004-03-19 發送簡訊給我 |
|
timhuang
尊榮會員 ![]() ![]() ![]() ![]() ![]() ![]() 發表:78 回覆:1815 積分:1608 註冊:2002-07-15 發送簡訊給我 |
Hi, 請說明資料庫種類以方便回答.
若是 sql server 的話, 可以使用 dts 來處理即可, 如圖所示,
1. 在你要複製的來源資料庫按右鍵選匯出資料,
|
yx_huang77
一般會員 ![]() ![]() 發表:46 回覆:64 積分:22 註冊:2004-03-19 發送簡訊給我 |
|
pillar62
資深會員 ![]() ![]() ![]() ![]() ![]() 發表:9 回覆:324 積分:271 註冊:2002-04-15 發送簡訊給我 |
|
yx_huang77
一般會員 ![]() ![]() 發表:46 回覆:64 積分:22 註冊:2004-03-19 發送簡訊給我 |
|
silence
一般會員 ![]() ![]() 發表:9 回覆:17 積分:10 註冊:2003-06-04 發送簡訊給我 |
底下是從 SQL Server 線上叢書找到的
DTS 的程式範例, 不過是 VB 版
你可以從 C:\Program Files\Microsoft SQL Server\80\Tools\Devtools\Samples\Dts\Dtstasks\DTSCopyDatabase 找到範例專案檔 .vpb
裡面引用 SQL Server 的 DTS Dll
custtask.dll#Microsoft DTS Custom Tasks Object Library
dtspump.dll#Microsoft DTSDataPump Scripting Object Library
dtspkg.dll#Microsoft DTSPackage Object Library
如果你剛好是用 VB, 或是會把他轉成 Delphi
就可以用自己寫的程式來做
手邊沒有 VB, 不然可以直接 compile 看看 [摘錄主要片段]
Private Sub GenericTaskPackage()
'Run the supplied package (*.dts)
Dim oConnection As DTS.Connection
Dim oStep As DTS.Step
Dim oTask As DTS.Task
Dim oCustomTask As DTS.TransferObjectsTask 'TaskObject On Error GoTo PackageError Set oPackageEvents = oPackage 'Create step, tasks
'Connections are not necessary when transfering objects. In general are needed when pumping data
Set oStep = oPackage.Steps.New
Set oTask = oPackage.Tasks.New("DTSTransferObjectsTask")
Set oCustomTask = oTask.CustomTask 'Fail the package on errors
oPackage.FailOnError = False With oStep
.Name = "Copy Database Step"
.ExecuteInMainThread = True
End With With oTask
.Name = "GenericPkgTask"
End With
'Customize the Task Object
With oCustomTask
.Name = "DTSTransferObjectsTask"
'SourceServer property specifies the name of the source server
.SourceServer = "(local)"
'SourceUseTrustedConnection property specifies whether the Windows Authentication security mode is to be used
.SourceUseTrustedConnection = True
'SourceDatabase property specifies the name of the source database
.SourceDatabase = sDatabase1
'DestinationServer property specifies the name of the destination server when you transfer SQL Server objects
.DestinationServer = "(local)"
'DestinationUseTrustedConnection property specifies whether Windows Authentication is used
.DestinationUseTrustedConnection = True
'DestinationDatabase property specifies the name of the destination database to use
.DestinationDatabase = sDatabase2
'ScriptFileDirectory property specifies the directory to which the script file and log files are written
'.ScriptFileDirectory = 'path must exist
'CopyAllObjects property specifies whether to transfer all objects
.CopyAllObjects = True
'IncludeDependencies property specifies whether dependent objects are scripted and transferred during a transfer
.IncludeDependencies = False
'IncludeLogins property specifies whether the logins on the source are scripted and transferred
.IncludeLogins = False
'IncludeUsers property specifies whether the database users on the source are scripted and transferred
.IncludeUsers = False
'DropDestinationObjectsFirst property specifies whether to drop objects, if they already exist on the destination
.DropDestinationObjectsFirst = True
'CopySchema property specifies whether database objects are copied
.CopySchema = True
'CopyData property specifies whether data is copied and whether existing data is replaced or appended to
.CopyData = DTSTransfer_ReplaceData
End With
oStep.TaskName = oCustomTask.Name 'Add the step
oPackage.Steps.Add oStep
oPackage.Tasks.Add oTask
'Run the package and release references.
oPackage.Execute
'Clean up
Set oCustomTask = Nothing
Set oTask = Nothing
Set oStep = Nothing
oPackage.UnInitialize Exit Sub
|
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |