求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
------解决方案--------------------
------解决方案--------------------还有其它方法吗?
------解决方案--------------------SQL code
select col1,col2,identity(int,1,1) col3 into #tb from tb
select * from #tb
------解决方案--------------------
SQL code
--增加col3列
alter table tb add col3 int
--修改col3列
update tb set col3=cast (right(col1,1) as int)
--排序查询
select * from tb order by col3