你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

New-AzDataMigrationSqlServerSchema

将 Sql Server 架构从源 Sql Server 迁移到目标 Azure Sql Server。

语法

ConfigFile (默认值)

New-AzDataMigrationSqlServerSchema
    -ConfigFilePath <String>
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

CommandLine

New-AzDataMigrationSqlServerSchema
    -Action <String>
    -SourceConnectionString <String>
    -TargetConnectionString <String>
    [-InputScriptFilePath <String>]
    [-OutputFolder <String>]
    [-PassThru]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

说明

将 Sql Server 架构从源 Sql Server 迁移到目标 Azure Sql Server。

示例

示例 1:使用参数运行将数据库对象从源 SQL Server 迁移到目标 Azure SQL 数据库

New-AzDataMigrationSqlServerSchema -Action "MigrateSchema" -SourceConnectionString "Server=;Initial Catalog=;User ID=;Password=" -TargetConnectionString "Server=;Initial Catalog=;User ID=;Password="
Starting schema migration...

Total number of object collected: 35
Total elapsed time: 00:00:08.8905823
DDL triggers: 4
Full text catalogs: 2
Plan guides: 2
Roles: 1
Schemas: 5
Stored procedures: 5
Tables: 10
User defined functions: 4
Users: 2

The number of scripted objects: 55
Progress: 100%
Total elapsed time: 00:00:39.9983180

The number of deployed script batches: 110/110
Progress: 100%
Total elapsed time: 00:00:05.6789103

此命令使用连接字符串在给定的 SQL Server 上运行 SqlServerSchema 迁移。

示例 2:使用参数从源 SQL Server 运行生成 TSQL 架构脚本

New-AzDataMigrationSqlServerSchema -Action "GenerateScript" -SourceConnectionString "Server=;Initial Catalog=;User ID=;Password=" -TargetConnectionString "Server=;Initial Catalog=;User ID=;Password=" -OutputFolder "C:\OutputFolder"
Starting schema script generation...

Total number of object collected: 35
Total elapsed time: 00:00:07.3789860
DDL triggers: 4
Full text catalogs: 2
Plan guides: 2
Roles: 1
Schemas: 5
Stored procedures: 5
Tables: 10
User defined functions: 4
Users: 2

The number of scripted objects: 55
Progress: 100%
Total elapsed time: 00:00:40.9745837

此命令使用连接字符串在给定的 SQL Server 上运行“生成 TSQL 架构脚本”。

示例 3:使用参数运行将 TSQL 脚本部署到目标 Azure SQL 数据库

New-AzDataMigrationSqlServerSchema -Action "DeploySchema" -SourceConnectionString "Server=;Initial Catalog=;User ID=;Password=" -TargetConnectionString "Server=;Initial Catalog=;User ID=;Password=" -InputScriptFilePath "C:\OutputFolder\script.sql"
Starting schema deployment...

The number of deployed script batches: 110/110
Progress: 100%
Total elapsed time: 00:00:05.7519257

此命令使用连接字符串将 TSQL 脚本部署到给定 SQL Server 上的目标 Azure SQL 数据库。

示例 4:使用 ConfigFile 运行将数据库对象从源 SQL Server 迁移到目标 Azure SQL 数据库

New-AzDataMigrationSqlServerSchema -ConfigFilePath "C:\configfile.json"
configfile.json example:
{
  "Action": "GenerateScript",
  "sourceConnectionString": "Server=;Initial Catalog=;User ID=;Password=",
  "targetConnectionString": "Server=;Initial Catalog=;User ID=;Password=",
  "inputScriptFilePath": "C:\OutputFolder\script.sql",
  "outputFolder": "C:\OutputFolder\script.sql"
}

Starting schema deployment...

The number of deployed script batches: 110/110
Progress: 100%
Total elapsed time: 00:00:05.7519257

此命令使用配置文件运行从源 Sql Server 到目标 Azure Sql Server 的 SqlServerSchema 命令。

参数

-Action

必填。 选择一个架构迁移作。 有效值为:MigrateSchema、GenerateScript、DeploySchema。 MigrateSchema 将数据库对象迁移到 Azure SQL 数据库目标。 GenerateScript 用于生成可编辑的 TSQL 架构脚本,该脚本可用于在目标上运行以部署对象。 DeploySchema 是运行从目标上 -GenerateScript作生成的 TSQL 脚本来部署对象。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

CommandLine
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-ConfigFilePath

ConfigFile 的路径

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

ConfigFile
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-Confirm

在运行 cmdlet 之前,提示你进行确认。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:cf

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-InputScriptFilePath

可选。 可编辑 TSQL 架构脚本的位置。 仅对 DeploySchema Action 使用此参数。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

CommandLine
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-OutputFolder

可选。 默认值:%LocalAppData%/Microsoft/SqlSchemaMigrations) 文件夹,其中日志将由 GenerateScript作写入和生成的 TSQL 架构脚本。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

CommandLine
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-PassThru

将 Sql Server 架构从源 Sql Server 迁移到目标 Azure Sql Server。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-SourceConnectionString

必填。 源 SQL 实例的连接字符串,使用正式的连接字符串格式。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

CommandLine
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-TargetConnectionString

必填。 目标 SQL 实例的连接字符串,使用正式连接字符串格式。

参数属性

类型:String
默认值:None
支持通配符:False
不显示:False

参数集

CommandLine
Position:Named
必需:True
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

-WhatIf

显示 cmdlet 运行时会发生什么情况。 命令脚本未运行。

参数属性

类型:SwitchParameter
默认值:None
支持通配符:False
不显示:False
别名:无线

参数集

(All)
Position:Named
必需:False
来自管道的值:False
来自管道的值(按属性名称):False
来自剩余参数的值:False

CommonParameters

此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters

输出

Boolean