如何将SQL Server localDB升级到更新版本?

时间:2021-10-28 17:17:39

Is it possible to upgrade SqlServer localDB from 2012 to 2014?

是否可以将SqlServer localDB从2012升级到2014年?

We currently use version 11 from SQL Server 2012. I need to upgrade to version 12 from SQL Server 2014.

我们目前使用的是SQL Server 2012的版本11.我需要从SQL Server 2014升级到版本12。

I would like to be able to do it without losing my tables and data.

我希望能够在不丢失表格和数据的情况下完成。

I installed a new localDB but I then I don't have my data. It also has another name and I can't really change the config files since it's a team project.

我安装了一个新的localDB但是我没有我的数据。它还有另一个名称,我无法真正更改配置文件,因为它是一个团队项目。

I tried using the command line sqlLocalDB tool to create a 2014 version called v11.0 but it created it in the old 2012 version any way.

我尝试使用命令行sqlLocalDB工具创建一个名为v11.0的2014版本,但它在旧的2012版本中以任何方式创建它。

C:\Program Files\Microsoft SQL Server\120\Tools\Binn>sqllocaldb create v11.0
LocalDB instance "v11.0" created with version 11.0.3000.0.

C:\Program Files\Microsoft SQL Server\120\Tools\Binn>sqllocaldb create v12.0
LocalDB instance "v12.0" created with version 12.0.2000.8.

C:\Program Files\Microsoft SQL Server\120\Tools\Binn>sqllocaldb create aaaaa
LocalDB instance "aaaaa" created with version 12.0.2000.8.

Why would naming it v11.0 change which version was used?

为什么命名为v11.0会改变使用哪个版本?

How can I upgrade the existing v11.0?

如何升级现有的v11.0?

3 个解决方案

#1


13  

As stated in this link from MSDN (Not too well chosen title...) the conversion should be triggered somewhat just double clicking on the .mdf file... This didn't happened in my case (maybe because it's necessary to have the Sql Server Management Studio software or something similar for this to be truth).

正如MSDN中的这个链接所说的那样(选择不太好的标题......)只需双击.mdf文件即可触发转换......这种情况在我的情况下没有发生(也许是因为有必要Sql Server Management Studio软件或类似的东西是真实的)。

So, here is an alternative procedure:

所以,这是一个替代程序:

  • Open the "Server explorer" in Visual Studio

    在Visual Studio中打开“服务器资源管理器”

  • Click on the "Connect to database" icon on the upper left corner

    单击左上角的“连接到数据库”图标

  • Chose "Microsoft SQL Server" in the list and press Next

    选择列表中的“Microsoft SQL Server”,然后按“下一步”

  • Write this as the Server Name: (LocalDB)\MSSQLLocalDB

    将其写为服务器名称:(LocalDB)\ MSSQLLocalDB

  • Select "Attach a database file" in the options below and browser to your .mdf file

    在下面的选项中选择“附加数据库文件”,然后在浏览器中选择.mdf文件

  • Proceed and this should show a dialog asking you to trigger the conversion or not

    继续,这应显示一个对话框,要求您触发转换

And that's it. Not very intuitive at all, but effective. I haven't found any documentation on it other than te link mentioned before, all the other steps were pure intuition but worked for me, I hope for you too.

就是这样。根本不是很直观,但有效。除了之前提到的te链接,我还没有找到任何文档,所有其他步骤都是纯粹的直觉,但对我有用,我也希望你。

#2


6  

To target a specific version of LocalDb, use 12.0 or 11.0 as a parameter. For instance:

要定位特定版本的LocalDb,请使用12.0或11.0作为参数。例如:

sqllocaldb create "mydb" 12.0

sqllocaldb创建“mydb”12.0

The reason your command failed was because you were referencing the version incorrectly. This isn't all too clear in the -? info.

您的命令失败的原因是您错误地引用了该版本。这一点在 - ?信息。

Using "v12.0" as the first parameter merely sets the instance name. If no second version parameter is given, the default version is used.

使用“v12.0”作为第一个参数仅设置实例名称。如果未给出第二个版本参数,则使用默认版本。

#3


0  

It seems that v11.0 is a special name for the LocalDB 2012 automatic instance. And it is strictly tied to this version. While 2014 and 2016 versions share the same MSSQLLocalDB name for that purpose.

似乎v11.0是LocalDB 2012自动实例的特殊名称。它与此版本严格相关。虽然2014和2016版本为此目的共享相同的MSSQLLocalDB名称。

More about LocalDB instances

有关LocalDB实例的更多信息

#1


13  

As stated in this link from MSDN (Not too well chosen title...) the conversion should be triggered somewhat just double clicking on the .mdf file... This didn't happened in my case (maybe because it's necessary to have the Sql Server Management Studio software or something similar for this to be truth).

正如MSDN中的这个链接所说的那样(选择不太好的标题......)只需双击.mdf文件即可触发转换......这种情况在我的情况下没有发生(也许是因为有必要Sql Server Management Studio软件或类似的东西是真实的)。

So, here is an alternative procedure:

所以,这是一个替代程序:

  • Open the "Server explorer" in Visual Studio

    在Visual Studio中打开“服务器资源管理器”

  • Click on the "Connect to database" icon on the upper left corner

    单击左上角的“连接到数据库”图标

  • Chose "Microsoft SQL Server" in the list and press Next

    选择列表中的“Microsoft SQL Server”,然后按“下一步”

  • Write this as the Server Name: (LocalDB)\MSSQLLocalDB

    将其写为服务器名称:(LocalDB)\ MSSQLLocalDB

  • Select "Attach a database file" in the options below and browser to your .mdf file

    在下面的选项中选择“附加数据库文件”,然后在浏览器中选择.mdf文件

  • Proceed and this should show a dialog asking you to trigger the conversion or not

    继续,这应显示一个对话框,要求您触发转换

And that's it. Not very intuitive at all, but effective. I haven't found any documentation on it other than te link mentioned before, all the other steps were pure intuition but worked for me, I hope for you too.

就是这样。根本不是很直观,但有效。除了之前提到的te链接,我还没有找到任何文档,所有其他步骤都是纯粹的直觉,但对我有用,我也希望你。

#2


6  

To target a specific version of LocalDb, use 12.0 or 11.0 as a parameter. For instance:

要定位特定版本的LocalDb,请使用12.0或11.0作为参数。例如:

sqllocaldb create "mydb" 12.0

sqllocaldb创建“mydb”12.0

The reason your command failed was because you were referencing the version incorrectly. This isn't all too clear in the -? info.

您的命令失败的原因是您错误地引用了该版本。这一点在 - ?信息。

Using "v12.0" as the first parameter merely sets the instance name. If no second version parameter is given, the default version is used.

使用“v12.0”作为第一个参数仅设置实例名称。如果未给出第二个版本参数,则使用默认版本。

#3


0  

It seems that v11.0 is a special name for the LocalDB 2012 automatic instance. And it is strictly tied to this version. While 2014 and 2016 versions share the same MSSQLLocalDB name for that purpose.

似乎v11.0是LocalDB 2012自动实例的特殊名称。它与此版本严格相关。虽然2014和2016版本为此目的共享相同的MSSQLLocalDB名称。

More about LocalDB instances

有关LocalDB实例的更多信息