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())
    

      

  • 相关阅读:
    数据结构笔记(一)
    Distance dependent Chinese Restaurant Processes
    距离依赖中餐馆过程
    AOP技术-02
    AOP技术-01
    Oracle-06
    web-02-css01
    web-02-css
    web-01
    jQuery对ajax的支持
  • 原文地址:https://www.cnblogs.com/igoogleyou/p/SQLServer2000error.html
Copyright © 2011-2022 走看看