得到表中除Col1、Col2的所有列
例如:userno_fm、userno_to
create table test(
num int identity(1,1),
userno_fm varchar(10),
userno_to varchar(10),
username varchar(10))
select * from test
declare @sql varchar(8000)
select @sql=''
select @sql=@sql+','+[name] from
(select [name] from syscolumns where object_id(N'[test]')=[id] and [name] not in ('userno_fm','userno_to')) A
set @sql='select '+stuff(@sql,1,1,'')+' from [test]'
--print @sql
exec (@sql)
drop table test