declare @t table (col varchar(50))insert @tselect '192.168.40.11' union all select '192.168.40.12' union all select '192.168.40.2' union all select '192.168.5.2'select * from @t order by col desccol -------------------------------------------------- 192.168.5.2 192.168.40.2 192.168.40.12 192.168.40.11(所影响的行数为 4 行)
declare @a table(id varchar(20)) insert @a select '192.168.5.2' union all select '192.168.40.12' union all select '192.168.40.2 ' union all select '192.168.40.11'select id from @A order by cast(parsename(id,4) as int),cast(parsename(id,3) as int) ,cast(parsename(id,2) as int),cast(parsename(id,1) as int)
(col varchar(50))insert @tselect '192.168.40.11' union all
select '192.168.40.12' union all
select '192.168.40.2' union all
select '192.168.5.2'select * from @t order by col desccol
--------------------------------------------------
192.168.5.2
192.168.40.2
192.168.40.12
192.168.40.11(所影响的行数为 4 行)
insert @a
select '192.168.5.2' union all
select '192.168.40.12' union all
select '192.168.40.2 ' union all
select '192.168.40.11'select id from @A
order by cast(parsename(id,4) as int),cast(parsename(id,3) as int) ,cast(parsename(id,2) as int),cast(parsename(id,1) as int)
谢谢指点~!