求Sql 语句(SqL server 2000)
tb
col1 col2
a01 ads
a04 ads
a02 ads
a03 ads
得到:(新增一列col3排序)
tb
col1 col2 col3
a01 ads 1
a02 ads 2
a03 ads 3
a04 ads 4
在sql server 2000中怎么实现??
[解决办法]
select *,'' as col3 from tb
[解决办法]
select col1,col2,identity(int,1,1) col3 into #tb from tbselect * from #tb
[解决办法]
--增加col3列alter table tb add col3 int--修改col3列update tb set col3=cast (right(col1,1) as int) --排序查询select * from tb order by col3