关于MSSql 2005 数据库的排序规则
2009-04-13 11:51
501 查看
between "Chinese_PRC_CI_AS" and "SQL_Latin1_General_CP1_CI_AS"的问题 某网友的解决办法: 该办法在使用where或inner join时没有区别 DataTable t = Luo.Base.ExecuteSql4Ds("select [游船时刻表].*,[游船].[星级],[游船].[向上价格],[游船].[向下价格],[游船].[静态文件名] from [游船时刻表] inner join [游船] on [游船时刻表].[游船名称] COLLATE SQL_Latin1_General_CP1_CI_AS =[游船].[游船名称] order by [游船时刻表].[游船名称]").Tables[0]; 或DataTable father_table = Luo.Base.ExecuteSql4Ds("select [行程类型].[行程类型名称] from [行程类型] where [行程类型].[行程类型名称] COLLATE SQL_Latin1_General_CP1_CI_AS in(select [行程].[行程类型] from [行程])").Tables[0]; DataTable son_table = Luo.Base.ExecuteSql4Ds("select * from [行程] where [行程].[行程类型] COLLATE SQL_Latin1_General_CP1_CI_AS in(select [行程类型].[行程类型名称] from [行程类型] where [行程类型].[行程类型名称] COLLATE SQL_Latin1_General_CP1_CI_AS in(select [行程].[行程类型] from [行程]))").Tables[0]; father_table.TableName = "t1"; son_table.TableName = "t2"; DataSet ds = new DataSet(); ds.Tables.Add(father_table.Copy()); ds.Tables.Add(son_table.Copy()); ds.Relations.Add("myrelation", ds.Tables[0].Columns["行程类型名称"], ds.Tables[1].Columns["行程类型"]); Repeater_tourtype.DataSource = ds.Tables[0]; Repeater_tourtype.DataBind(); 以下是在网上搜索到的: 最近在测试程序的时候,因为我总是不停地换数据库测试,发现了一个问题,在有些库里面运行正常的程序,在另外一些库中就会出现错误,提示为: Msg 468, Level 16, State 9, Line 1 Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" and "SQL_Latin1_General_CP1_CI_AS" in the equal to operation. 出现这样的错误的代码中,都有创建临时表“create table #tmp(。。。)”这样的操作,因为数据库都是从标准测试库中备份恢复出来的,估计是因为字符集不一样的原因。解决的方法是在创建临时表的时候增加collate database_default。 例如: create table #tmp (code nvarchar(10) collate database_default) 另一种说法: Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Chinese_PRC_CI_AS" in the equal to operation?? 使用的数据库是英文的 是不是语言问题 怎么解决?? 1排序规则冲突。什么操作时引起的? 2看看你表的字段排序规则是否一致。 3再加上Collate子句好了 原因是有两种排序规则,必须显示指定其中一种 把语句贴出来更好说明一点 4操作时指定COLLATE 5将表结构里字段排序规则 改为一致就可以了 6WHERE A.Column COLLATE SQL_Latin1_General_CP1_CI_AS = B.Column 第三种说法: 在SQL Server端不能将汉字作为查询条件 我使用一个系统,开发工具为PB9.0,数据库为SQL Server2000英文版,我们的用户在前端可正 常输入汉字,我也可在SQL Query Analyzer查看到汉字,但当我在SQL Query Analyzer上用汉字 作为查询条件时,就查不出记录,如下查询语句: select * from employee where empname='张华'. 但是在PB9.0端可以查询。 请问:有谁知道怎样解决及什么原因?谢谢! set quoted_identifier on 开启分隔标示符。 谢谢KAKAJE的回答,我设定了set quoted_identifier on, 但执行以汉字为查询条件的语句时, 仍然不能返回记录,如下语句: select * from employee where empname='张华' OR select * from employee where empname=N'张华'. 请问:我还可以怎样做?及设定set quoted_identifier on 对数据库是否有影响?谢谢! 你试试这个行不行 select * from employee where ename like '%张华%' like语句也是不可以的,我想应该是SQL Server不能正确转化汉字的内码,但我不知道应怎样做 ? what is the collation of the employee table name column, it should like: chinese_prc_...... The column's collation is: SQL_Latin1_General_CP1_CI_AS, and this is database defualt value. because the SQL Server2000 is been upgraded from SQL Server6.5, I use all default setting according to SQL Server6.5. and I don't dare modifing the collation because I worry about there are any error caused. SQL_Latin1_General_CP1_CI_AS is usually used from english edition. You can set your NAME table as nchar or nvarchar data type, and use Chinese_Prc_CI_AS as the column collation. It will work fine for both english and chinese name. When you insert/query data, always use N'张华' as your constant expression, since it will treat it as a unicode string instead of a ANSI string. Thank you: qingsongy. Now My database exists the following some case: 1. The collation of Database: SQL_Latin1_General_CP1_CI_AS . and I don't know whether can change its collation to Chinese_Prc_CI_AS and how to change? 2. When I want to change the column: empname's collation from <database Default> to Chinese_Prc_CI_AS, there is a error encountered and can't be changed, the error as follows: 'employee' table - Unable to modify table. ODBC error: [Microsoft][ODBC SQL Server Driver][SQL Server]Line 4: Incorrect syntax near 'COLLATE'. Please ask how to solve it? 3. There isn't Chinese_Prc_CI_AS the option in [SQL Collation], Only [Windows Collation] includes it. Please ask the difference between [SQL Collation] and [Windows Collation]? At fact, I made a testing database and the testing database's collation is Chinese_Prc_CI_AS, then I copy all data from living database. On SQL Server I can enquiry relevant records by chinese enquiry condition. By the way, My SQL Server IS SQL Server2000 English Standard Edition. |
相关文章推荐
- 关于Mssql 2005 数据库备份 步骤
- SQL Server 2005数据库的排序规则相关知识
- 关于MSSQL2005还原数据库异常的记录
- NopCommerce学习:MSSQL 2005 排序规则导致中文编码错误
- SQL SERVER 2005 由于默认排序规则造成多数据库查询报错的问题
- 关于数据库排序规则的修改
- MSSQL数据库排序规则如何更改
- 关于MSSQL2005 数据库关系图无法使用
- MSSQL数据库排序规则如何更改
- MSSQL 修改数据库的排序规则
- 关于解决数据库修改排序规则
- SQL Server 2005数据库的排序规则相关知识介绍
- mysql 数据库排序规则
- 关于查看MSSQL 数据库 用户每个表 占用的空间大小
- sql server2005新建数据库时的排序规则
- MSSQL 2005 数据库变成可疑状态
- 关于:无法执行值从 char 到 char 的隐性转换,因为该值的排序规则因排序规则冲突而未能解决
- MSSQL 2005 数据库变成可疑
- 修改MsSql( sql server)的排序规则
- 数据库及ADO.NET---- ABCDEFGHI...abcdef 变为AaBbCdDdEeFf........排序规则的变化