当前位置: 数据库>sqlserver
获取sql server表中的所有列字段名称的方法
来源: 互联网 发布时间:2014-08-29
本文导语: 创建一个存储过程,获取sql server表中的所有列字段名称。 代码如下: Create Proc pAllColumnSql (@tableName varchar(50)) as Declare @Name Varchar(2000) set @Name =’’ select @Name =@Name + ’,’ + Cast([name] as Varchar) from syscolumns where ...
创建一个存储过程,获取sql server表中的所有列字段名称。
代码如下:
Create Proc pAllColumnSql
(@tableName varchar(50))
as
Declare @Name Varchar(2000)
set @Name =’’
select @Name =@Name + ’,’ + Cast([name] as Varchar)
from syscolumns
where id=object_id(@tableName)
set @name = substring(@name,2,len(@name)-1)
select @name
(@tableName varchar(50))
as
Declare @Name Varchar(2000)
set @Name =’’
select @Name =@Name + ’,’ + Cast([name] as Varchar)
from syscolumns
where id=object_id(@tableName)
set @name = substring(@name,2,len(@name)-1)
select @name