日期:2014-05-18  浏览次数:20416 次

MS_SQL的函数问题,高手进啊
我想写个函数,参数是一个自定义的表名,返回这个表的行数

------解决方案--------------------
create function backtoCount(@tablename varchar(50))
returns int
as
begin
declare @count int
select @count=rows from sysindexes where indid in (0,1) and object_name(id)=@tablename
return @count
end
GO
--查sysobjects表有多少行
select dbo.backtoCount( 'sysobjects ')