tsql - Sorting a column having special charaters in SQL Server 2008 -


i have table column name nvarchar(100).

the data in table looks this:

wang bergeron zhang sorrentino mazumdar boggs fricker barkwell atkinson mah test cb1 c1*( --test contact-- --test contact-- --abc contact-- retest contact janzen seto boggs fricker barkwell 

and expecting results

--abc contact-- --test contact-- --test contact-- atkinson barkwell barkwell bergeron boggs boggs fricker fricker janzen mah mazumdar retest contact seto sorrentino test cb1 c1*( wang zhang 

request kind support re-solve sorting

you use case-statement in order by.

declare  @temp table(     name varchar(100) ) insert @temp      select * (select 'wang' union select 'bergeron' union select 'zhang' union select 'sorrentino' union select 'mazumdar' union select 'boggs' union select 'fricker' union select 'barkwell' union select 'atkinson' union select 'mah' union select 'test cb1 c1*(' union select '--test contact--' union select '--test contact--' union select '--abc contact--' union select 'retest contact' union select 'janzen' union select 'seto' union select 'boggs' union select 'fricker' union select 'barkwell')as t(spalte);  select * @temp     order (case when [name] '-%' 0 else 1 end), [name] 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -