create function dbo.fun(@inputid as varchar(40)) returns int as begin declare @counts int select @counts=COUNT(*) from Stu_Infor return @counts end declare @input varchar(40) set @input='2' select dbo.fun(@input)
自己写个小例子
http://www.cnblogs.com/no7dw/archive/2010/07/08/1773495.html
很详细