declare @testtable table (test nvarchar(max))
insert into @testtable (test) values ('1.2.3')
insert into @testtable (test) values ('1.20.3')
insert into @testtable (test) values ('1.19.x')
insert into @testtable (test) values ('1.x.x')
insert into @testtable (test) values ('1.19.3')
insert into @testtable (test) values ('DEC09')
insert into @testtable (test) values ('Plutonium')
insert into @testtable (test) values ('dec09')
insert into @testtable (test) values ('N/A')
insert into @testtable (test) values ('MyTest20')
insert into @testtable (test) values ('20MyTest')
insert into @testtable (test) values ('1.4.18')
insert into @testtable (test) values ('1.4.168')
select * from @testtable
order by test asc;
其輸出
1.19.3
1.19.x
1.2.3
1.20.3
1.4.168
1.4.18
1.x.x
20MyTest
DEC09
dec09
MyTest20
N/A
Plutonium
但我想輸出爲了
1.2.3
1.4.18
1.4.168
1.19.3
1.19.x
1.20.3
1.x.x
20MyTest
DEC09
dec09
MyTest20
Plutonium
N/A
(注意N/A是「魔術」並且總是最大,「版本」(例如1.2.3)總是有3位數,儘管一個或多個數字可能是char x指示「任何數字」,這應該始終被認爲是最大可能的數字)
如何在SQL Server中完成此操作?
+ 1用於DDL和INSERT。哪個SQL Server版本? – 2012-04-23 09:41:47
這個版本是不同的,因爲解決方案將被放置在不同的服務器上 – Millerbean 2012-04-23 10:55:00
* How *不同?你想要運行的最早版本是什麼?請添加適當的標籤。 – 2012-04-23 13:09:46