欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

获得MSSQL表中的所有列字段名称的方法(存储过程)

程序员文章站 2022-03-07 15:49:00
...

原文地址: http://www.haokaoshi.com/html/jsjdj/3j/sjk/fd/37567.html SQL Server Create Proc pAllColumnSql (@tableName varchar(50)) as Declare @Name Varchar(2000) set @Name =’’ select @Name =@Name + ’,’ + Cast([name] as Varchar) from sys

原文地址: http://www.haokaoshi.com/html/jsjdj/3j/sjk/fd/37567.html 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