我正在尝试从 microsoft sql server 2003 迁移到 sql server 2016。使用 Microsoft SQL Management Studion 2016 导入数据进展顺利,但未导入视图。这是我的要求,如何导入视图?
此时我尝试了:
- 从旧数据库生成创建脚本,但似乎回到 2003 年,这个选项不存在
- 在旧 SQL 服务器中进行查询以列出所有视图,复制它们并在新服务器中手动重新创建它们,但没有查询可以检索所有视图
- 从旧服务器复制 .MDF 和 .LDF 文件,并将它们附加到新服务器,但出现以下错误:
=
==================================
Fail to join database for serber « DESKTOP-53C6I45\SQLEXPRESS ». (Microsoft.SqlServer.Smo)
------------------------------
To get help, click on : http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=13.0.16106.4+((SSMS_Rel_16_5).170125-2137)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Attacher+la+base+de+données+Server&LinkId=20476
------------------------------
Software location :
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabase(String name, StringCollection files)
at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.Attach()
at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.SendDataToServer()
===================================
An exception was produced during the execution of batch Transact-SQL. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
Location of the software :
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(StringCollection sqlCommands, ExecutionTypes executionType, Boolean retry)
at Microsoft.SqlServer.Management.Smo.ExecutionManager.ExecuteNonQuery(StringCollection queries, Boolean retry)
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabaseWorker(String name, StringCollection files, String owner, AttachOptions attachOptions)
at Microsoft.SqlServer.Management.Smo.Server.AttachDatabase(String name, StringCollection files)
===================================
The database 'Labeint' can't be upgraded, because its non final version (539) isn't managed by this version of SQL Server. You can't open a database which is incompatible with this version of sqlservr.exe. You must rereate the database.
Impossible to open the new database 'Labeint'. Abandon of CREATE DATABASE. (.Net SqlClient Data Provider)
------------------------------
To get help, click on : http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=950&LinkId=20476
------------------------------
Server name : DESKTOP-53C6I45\SQLEXPRESS
Error number : 950
Gravity : 20
State: 1
Line number : 1
------------------------------
Location of the software :
at Microsoft.SqlServer.Management.Common.ConnectionManager.ExecuteTSql(ExecuteTSqlAction action, Object execObject, DataSet fillDataSet, Boolean catchException)
at Microsoft.SqlServer.Management.Common.ServerConnection.ExecuteNonQuery(String sqlCommand, ExecutionTypes executionType, Boolean retry)
问题是旧项目中的视图很复杂,我不知道在哪里获取对我来说是黑匣子的项目的数据,否则我会手动重新创建它们,试图弄清楚它们是如何制作的。