/****** Object: Stored Procedure dbo.sp_table_columnList Script Date: 2008-12-24 1:19:12 ******/
/*********************************************************
列出资料表所有记录
**********************************************************/
Create procedure @tableName sysName
as
exec(' select * From '+@tableName)
go
/****** Object: Stored Procedure dbo.sp_table_columnList Script Date: 2008-12-24 1:19:12 ******/
/*********************************************************
列出资料表所有列名
**********************************************************/
Create procedure sp_table_columnList
@tablename sysname
as
declare @str varchar(8000)
set @str=''
select @str=Rtrim(@str)+','+Rtrim(name) from syscolumns
where id=object_id(@tablename)
order by colorder
if Rtrim(@str)=''
begin
select @str=Rtrim(@str)+','+Rtrim(name) from tempdb..syscolumns
where id=object_id('tempdb..'+@tablename)
order by colorder
end
if rtrim(@str)<>''
begin
set @str=substring(@str,2,len(@str)-1)
print @str
end
else
Print '系统中不存在资料表:'+@tablename
GO