--如果name不重复,可以用:select id=(select count(*) from table1 where name<=a.name)
,name,birth 
from table1 a
order by name

解决方案 »

  1.   

    --如果不满足这个条件,得用临时表select id=identity(int,1,1),name,birth 
    into #t from table1 a
    order by nameselect * from #tdrop table #t
      

  2.   

    zjcxc(邹建):
    1)姓名有可能重复;2)建临时表的方法我实现了,可是每次用户在网页上提交都在服务器端生成临时表似乎并不是什么好的办法! 还有没有别的方法? 不过还是谢谢你!
      

  3.   


    --显示当前数据库的表结构信息  
     
    SELECT    
               表名=case  when  a.colorder=1  then  d.name  else  ''  end,  
               字段序号=a.colorder,  
               字段名=a.name,  
               标识=case  when  COLUMNPROPERTY(  a.id,a.name,'IsIdentity')=1  then  '√'else  ''  end,  
               主键=case  when  exists(SELECT  1  FROM  sysobjects  where  xtype='PK'  and  name  in  (  
                           SELECT  name  FROM  sysindexes  WHERE  indid  in(  
                                       SELECT  indid  FROM  sysindexkeys  WHERE  id  =  a.id  AND  colid=a.colid  
                           )))  then  '√'  else  ''  end,  
               类型=b.name,  
               占用字节数=a.length,  
               长度=COLUMNPROPERTY(a.id,a.name,'PRECISION'),  
               小数位数=isnull(COLUMNPROPERTY(a.id,a.name,'Scale'),0),  
               允许空=case  when  a.isnullable=1  then  '√'else  ''  end,  
               默认值=isnull(e.text,''),  
               字段说明=isnull(g.[value],'')  
    FROM  syscolumns  a  
               left  join  systypes  b  on  a.xtype=b.xusertype  
               inner  join  sysobjects  d  on  a.id=d.id    and  d.xtype='U'  and    d.name<>'dtproperties'  
               left  join  syscomments  e  on  a.cdefault=e.id  
               left  join  sysproperties  g  on  a.id=g.id  and  a.colid=g.smallid      
    order  by  a.id,a.colorder  
     
      

  4.   

    use 你的数据库
    SELECT  * FROM  sysobjects  where  xtype='PK'
      

  5.   

    jiangchuandong(奋斗成男人) :没明白你的意思,能说的详细些吗?