ASP 字母排列 问题

来源:百度知道 编辑:UC知道 时间:2024/09/21 05:31:40
ASP网站怎么像赶集网(http://www.ganji.com/)那样,把数据库里的城市按英文字母顺序排列,最好是不需要在数据库再建字段。
为了避免没人回答浪费分数,回答的好的追加悬赏30分,谢谢!
谢谢1楼的,不过是Access的数据库啊,不好意思忘了说了。

在SQL中建立以下函数,该函数可返回第一个汉字的拼音首字母。在查询时可以这样:
select *,f_GetFirstPy(title) as py from news order by f_GetFirstPy(title)

/****** 对象: UserDefinedFunction [dbo].[f_GetFirstPy] 脚本日期: 08/31/2008 10:54:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--取得字符串第一个汉字的拼音首字母
create function [dbo].[f_GetFirstPy](@str nvarchar(1))
returns nvarchar(1)
as
begin
declare @strlen int,@re nvarchar(1)
declare @t table(chr nchar(1) collate Chinese_PRC_CI_AS,letter nchar(1))
insert into @t(chr,letter)
select '吖','A' union all select '八','B' union all
select '嚓','C' union all select '咑','D' union all
select '妸','E' union all select '发','F' union all
select '旮','G' union all select '铪','H' union all
select '丌','J' union all select '咔',