5
5
. Description
6
6
Copies schema, structure (tables, views, etc.), to an empty SQL Server databaase. Also supports copying data via bcp.
7
7
8
- . Parameter ServerName
9
- Database to copy from
10
- . Parameter DestinationServer
8
+ . Parameter ServerName
9
+ Database to copy from
10
+ . Parameter DestinationServer
11
11
Database to copy to
12
- . Parameter SourceUser
12
+ . Parameter SourceUser
13
13
Database User for the source database
14
- . Parameter SourcePassword -
14
+ . Parameter SourcePassword -
15
15
Password for the source database
16
16
. Parameter DestinationUser
17
17
Database User for the destination database
18
- . Parameter DestinationPassword
18
+ . Parameter DestinationPassword
19
19
Password for the destination database
20
20
. Parameter SourceDatabase
21
21
Name of the databse to copy too
22
- . Parameter DestinationDB
22
+ . Parameter DestinationDB
23
23
Name of the destination database
24
- . Parameter CopyData
24
+ . Parameter CopyData
25
25
Flag to trigger bulk copy of data to destination database
26
- . Parameter fileName
26
+ . Parameter fileName
27
27
Path to the Schema.sql file included in this repo ".\ExtractDB\Schema.sql"
28
- . Parameter tempPath
28
+ . Parameter tempPath
29
29
A temp directory on a drive with enough free space to save the bcp files during the export and import operations ".\BCP\"
30
- . Parameter logPath
30
+ . Parameter logPath
31
31
Directory to write error logs too ".\log\"
32
32
33
33
34
34
#>
35
35
36
36
function copy-database {
37
37
param (
38
- $ServerName ,
38
+ $ServerName ,
39
39
$DestinationServer ,
40
40
$SourceUser ,
41
41
$SourcePassword ,
42
42
$DestinationUser ,
43
43
$DestinationPassword ,
44
- $SourceDatabase ,
44
+ $SourceDatabase ,
45
45
$DestinationDB ,
46
46
$CopyData ,
47
47
$fileName = " ..\ExtractDB\Schema.sql" ,
@@ -77,6 +77,7 @@ function copy-database{
77
77
}
78
78
}
79
79
}
80
+ Export-ModuleMember - Function copy-database
80
81
81
82
function copy-schema {
82
83
param (
@@ -91,14 +92,14 @@ function copy-schema {
91
92
{
92
93
$error | Out-File - FilePath " $ ( $ErrorFile ) "
93
94
$sql.SqlStatement | Out-File - Append - FilePath " $ ( $ErrorFile ) "
94
-
95
+
95
96
$error.Clear ()
96
97
}
97
98
Write-Output $Sql
98
99
}
99
100
100
101
# TODO: Breakup into extract and import
101
- function copy-data {
102
+ function copy-data {
102
103
param (
103
104
[string ] $SchemaName ,
104
105
[string ] $TableName ,
0 commit comments