如何在连接字符串中传递collat​​e id [英] How can I pass collate id in a connection string

查看:43
本文介绍了如何在连接字符串中传递collat​​e id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过连接字符串设置排序规则SQL Server。



有没有什么方法可以通过c#代码设置或更改数据库中的排序规则值?



我很难找到解决这个问题的方法。

提前谢谢

How can i set the collation SQL Server through connection string.

Is there any way I can set or change the value of collation in database through c# code?

I am having a trouble time finding the solution to this issue.
Thanks in advance

推荐答案

ConnectionString仅用于提供连接。



如果要设置排序规则,则为此创建存储过程。

ConnectionString is used only for providing connection.

If you want to set the collation then you have create stored procedure for that.
create proc SETCollate
@collateString nvarchar(255)
As
BEGIN
declare @qry nvarchar(500)
set @qry = 'ALTER DATABASE [DatabaseName]; COLLATE '+@collateString+';'
EXECUTE sp_executesql @qry
END



然后你必须在你想要的时候从代码中执行这个存储过程。请输入你要设置的整理字符串。


Then you have to execute this stored procedure from code when you want.Pass the collate string which you want to set.


这篇关于如何在连接字符串中传递collat​​e id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆