CREATE FUNCTION dbo.ffff()
RETURNS datetime AS  
BEGIN
declare @temp datetime
set @temp=(select getdate())
return @temp
END报错:在函数内不正确地使用了 'getdate'。
何解??

解决方案 »

  1.   

    函数中不能用getdate()你可以传入参数或调用视图
      

  2.   

    参考:
    http://community.csdn.net/Expert/topic/4936/4936066.xml?temp=.864895
      

  3.   

    CREATE VIEW GETDATES
    AS
    SELECT GETDATE() as 'CURRDATE'
    --
    CREATE FUNCTION dbo.ffff()
    RETURNS datetime AS  
    BEGIN
    declare @temp datetime
    set @temp=(select CURRDATE FROM GETDATES) --在函数内调用视图
    return @temp
    END