简体   繁体   English

更改SQL Server Compact 4.0的排序规则

[英]Alter collation of SQL Server Compact 4.0

Is it somehow possible to change collation of a .sdf-file? 是否可以更改.sdf文件的排序规则? I have tried Management Studio 2008 but it only supports version 3.5, Management Studio 2012 does not support SQL Server Compact at all as far as I can see, the SQL Server Compact Toolbox for Visual Studio does not seem to offer this possibility and ALTER DATABASE also seems to be missing - is there any solution at all? 我已经尝试过Management Studio 2008,但据我所知它仅支持3.5版,Management Studio 2012根本不支持SQL Server Compact,用于Visual Studio的SQL Server Compact Toolbox似乎没有提供这种可能性,并且ALTER DATABASE也似乎不见了-有什么解决办法吗?

Yes, there is a solution, the SqlCeEngine Compact method allows you to do that from code (it effectivly recreates the database file), or you can do it via my sqlcecmd command line utility. 是的,有一个解决方案,SqlCeEngine Compact方法允许您通过代码(有效地重新创建数据库文件)执行此操作,或者可以通过我的sqlcecmd命令行实用程序来执行此操作。

sqlcecmd -d "Data Source=C:\data\mydb.sdf" -z "Data Source=;LCID=1044"

Download from http://sqlcecmd.codeplex.com http://sqlcecmd.codeplex.com下载

I think that in order to change the collation on a .sdf file you will need to re-create it as a database in SQL Server: 我认为,为了更改.sdf文件的排序规则,您需要将其重新创建为SQL Server中的数据库:

USE master
GO
CREATE DATABASE "file.sdf" DATABASEPASSWORD '<Pwd>' COLLATE <the_Collation>
GO

If you have it already established as a database then you just need to alter the database: 如果已经将其建立为数据库,则只需更改数据库即可:

USE master
GO
ALTER DATABASE <the_Database>
COLLATE <new_Collation>
GO

Then you can re-compact the database and it will have the collation you require. 然后,您可以重新压缩数据库,它将具有所需的排序规则。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM