指这样??declare @a table ( a varchar(10) )insert into @a select '甲' union all select '丁' union all select '乙' union all select '丙'select * from @aselect * from @a order by charindex(a,'甲 乙 丙 丁')/*a ---------- 甲 丁 乙 丙 a ---------- 甲 乙 丙 丁 */
楼上的例子真不错,学习了。 表变量和列同名,要是不同名就更好了: declare @t table (a varchar(10))
什么字符集? 排序规则吧?order by 列 collate 排序规则名
按姓氏笔画排序: Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as不知道对不对呢
(
a varchar(10)
)insert into @a
select '甲' union all
select '丁' union all
select '乙' union all
select '丙'select * from @aselect * from @a order by charindex(a,'甲 乙 丙 丁')/*a
----------
甲
丁
乙
丙
a
----------
甲
乙
丙
丁
*/
表变量和列同名,要是不同名就更好了:
declare @t table (a varchar(10))
Select * From TableName Order By CustomerName Collate Chinese_PRC_Stroke_ci_as不知道对不对呢
谢谢