大家看看有没有错啊???关于SQL函数的!多谢了!!

CREATE FUNCTION getPic (@albumid int)
RETURNS int as
BEGIN
declare @icount as int
begin
select @icount = count(*) from toppic_pic where albumid = @albumid
end
return icount
END
go

老说我icount未定义是什么意思啊!
---------------------------------------------------------------

return icount是不是该改为return @icount
---------------------------------------------------------------

return @icount

带@的是它的局部变量
带@@的是全局变量
---------------------------------------------------------------

CREATE FUNCTION getPic (@albumid int)
RETURNS int as
BEGIN
declare @icount as int
begin
select icount = count(*) from toppic_pic where albumid = albumid
end
return icount
END
go

Published At
Categories with Web编程
Tagged with
comments powered by Disqus