/*
获取表中所有的列名,并用逗号隔开
select dbo.pAllColumnSql('tableName')
*/
create function pAllColumnSql
(
@tableName varchar ( 50 ) -- 表名
)
returns nvarchar ( 4000 )
as
begin
Declare @Name nvarchar ( 4000 )
set @Name = ''
select @Name = @Name + ' , ' + Cast ( [ name ] as Varchar ) from syscolumns
where id = object_id ( @tableName )
set @name = substring ( @name , 2 , len ( @name ) - 1 )
return @name
end
获取表中所有的列名,并用逗号隔开
select dbo.pAllColumnSql('tableName')
*/
create function pAllColumnSql
(
@tableName varchar ( 50 ) -- 表名
)
returns nvarchar ( 4000 )
as
begin
Declare @Name nvarchar ( 4000 )
set @Name = ''
select @Name = @Name + ' , ' + Cast ( [ name ] as Varchar ) from syscolumns
where id = object_id ( @tableName )
set @name = substring ( @name , 2 , len ( @name ) - 1 )
return @name
end