zoukankan      html  css  js  c++  java
  • sqlServer2000 中自定义函数中 getdate() 函数不识别

    在 SQL Server 2008 中,自定义 函数 :

      

    Create function CurrentMonthFirstDay()
    returns Datetime
    as
    begin
     DECLARE @FistDayOfCurrentMonth DATETIME
     SET @FistDayOfCurrentMonth = DATEADD(mm,DATEDIFF(mm,0,getdate()),0) 
     return @FistDayOfCurrentMonth
    end
    

      发现在2000中 不能运行, 首先 getedate() 不识别   ----- 改为 dbo.getdate().  可用生产了,但是不能执行,还是dbo.getdate() 的问题。

    在网上找了下解决办法 。

    将getdate() 作为参数传人:

    Create function CurrentMonthFirstDay( @dt DATATIME)
    returns Datetime
    as
    begin
     DECLARE @FistDayOfCurrentMonth DATETIME
     SET @FistDayOfCurrentMonth = DATEADD(mm,DATEDIFF(mm,0,dt),0) 
     return @FistDayOfCurrentMonth
    end
    
    select  dbo.CurrentMonthFirstDay(getdate())
    

      

  • 相关阅读:
    第二天课程档案
    第一天课程档案
    SAM初步
    计算几何初步
    数论二次总结
    生成函数入门题汇总
    1500: [NOI2005]维修数列
    20170214
    【bzoj2286】[Sdoi2011]消耗战
    bzoj2223: [Coci 2009]PATULJCI
  • 原文地址:https://www.cnblogs.com/igoogleyou/p/SQLServer2000error.html
Copyright © 2011-2022 走看看