查询某表的所有字段名:
declare @s varchar(1000)
select @s = isnull(@s+',', '') + [name] from syscolumns where id = object_id('表名')
select @s
--select name from sysobjects where type=1 and flags=0
--select name from sysobjects where type='U'
查询数据库中所有表名:
select Name from sysobjects where xtype='u' and status>=0
把某表中某列的所有值组成一个字符串返回:
declare @s varchar(8000)
select @s=isnull(@s,'')+rtrim(列名)+',' from 表名
select @s as result