易截截图软件、单文件、免安装、纯绿色、仅160KB

Sql排序 - MS-SQL Server / 基础类

我的Tblworkbill表的数据如下:

id workbillno ..................
1 1
2 6
3 a1
4 c2
5 2
6 aa
7 a2
8 5
9 7
10 d3
11 b1
. .
. .
. .
. .

如何将workbillno排序为:
1
2
5
6
7
a1
a2
b1
c2
d3
aa

SQL code:

--> 测试数据:[TB]
if object_id('[TB]') is not null drop table [TB]
create table [TB]([id] int,[workbillno] varchar(2))
insert [TB]
select 1,'1' union all
select 2,'6' union all
select 3,'a1' union all
select 4,'c2' union all
select 5,'2' union all
select 6,'aa' union all
select 7,'a2' union all
select 8,'5' union all
select 9,'7' union all
select 10,'d3' union all
select 11,'b1'


create function dbo.f_ASCII(@s varchar(50)) returns int
as
begin
declare @i int
set @i=0
while len(@s)>0
begin
set @i=@i+ASCII(left(@s,1))
set @s=right(@s,len(@s)-1)
end
return @i
end
go

select * from TB order by dbo.f_ASCII(workbillno)

/*
id workbillno
----------- ----------
1 1
5 2
8 5
2 6


相关问答:

csv文件转换成sql导入到数据库,没有数据为何?

执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......

求一SQL - MS-SQL Server / 基础类

表如下
教室ID 座位数 开始时间 结束时间 2009年1月1日 2009年1月2日 2009年1月3日
  101 50 08:00 08:30 30 40 50  
  101 50 09:00 ......

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

Asp+sql server问题 - Web 开发 / ASP

我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例: ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号