set nocount on createtable test(a varchar(10)) insertinto test select'a' insertinto test select'b' declare@str1varchar(8000) declare@str2varchar(8000) set@str1='' set@str2='' select@str1=@str1+a from test orderby a print@str1--返回ab select@str2=@str2+a from test orderby case a when'a'then1 when'b'then2else99end print@str2--返回b droptable test set nocount off