思路:
先用一个方法取出表中的所有字段
select name from syscolumns where id=object_id('表名')然后组成SQL需要的格式--将表名链接成串
select stuff((select ','+Convert(nvarchar,name) from
(select name from syscolumns where id=object_id('taxbill'))x for xml path('')),1,1,'')
本文介绍了一种从SQL表中提取所有字段的方法,并展示了如何通过组合这些字段来构造特定格式的SQL语句。这种方法对于自动化生成SQL脚本非常有用。
思路:
先用一个方法取出表中的所有字段
select name from syscolumns where id=object_id('表名')select stuff((select ','+Convert(nvarchar,name) from
(select name from syscolumns where id=object_id('taxbill'))x for xml path('')),1,1,'')
745

被折叠的 条评论
为什么被折叠?