2
declare @output varchar(8000)
select @output = coalesce(@output+',', '') + name from table
print @output

解决方案 »

  1.   

      方法1:
    truncate table 你的表名 --這樣不但將數據刪除,而且可以重新置位identity屬性的字段。方法2:
    delete from 你的表名
    dbcc checkident(你的表名,reseed,0) --重新置位identity屬性的字段,讓其下個值從1開始。
      

  2.   


    1.怎么样能让缓存表中的IDENTITY   列重新记录 
    例如定义@tb中ID,在用WHILE往里INSERT时候每次ID都标识都重新开始 2.有缓存表@tb 
    ID,Name 
    1,a 
    2,b 
    3,c 
    要查询显示成 
    a,b,c
    -------------------
    1、truncate table 表名
    2、declare @sql varchar(1000)
       select @sql=isnull(@sql+',','')+Name from @tb
       @sql即为a,b,c