SQL Server 中 NVARCHAR 列的 Order By 子句
我需要对 nvarchar
列进行排序。问题是该列没有相同的条目模式,该列的某些行的示例是
12
9
TEF
78F
T2R
如何按 order By 子句对该列进行排序?唯一令我宽慰的是该列仅包含数字和字母数字字符。
I need to make the order by for the nvarchar
column. The issue is this that the column doesn't have the same pattern of entry, example of some rows of the column are
12
9
TEF
78F
T2R
How to sort this column by order By clause? The only relief I have is that this column contains only numeric and alpha numeric characters.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
所以
变成
Which will sort正确
你不能依赖ISNUMERIC
So
becomes
Which will sort correctly
You can't rely on ISNUMERIC
我猜你的问题是它没有正确排序数字和文本。
本文介绍了一种方法:
如何对包含数字的 SQL Server 中的 VARCHAR 列进行排序?
来自文章:
I'm guessing that you issue is that its not sorting the numbers and text correctly.
This article explains one approach:
How do I sort a VARCHAR column in SQL server that contains numbers?
From the article: