Tags: function, functions, funtion, getdate, hai, improper, programming, simlpe, sql, userdefined

getdate() function

On Programmer » SQL

1,800 words with 2 Comments; publish: Thu, 29 May 2008 03:41:00 GMT; (20077.88, « »)

hai,

simlpe question

how to use getdate() funtion in userdefined functions ,if i am trying to use

this function , improper use of getdate () function

thanks in advance

All Comments

Leave a comment...

  • 2 Comments
    • MS has explicitly disallowed using non-deterministic system functions in a user defined function.

      This is because the function will be evaluated once per row (imagine a scalar function referred to

      in a column list of a SELECT statement), where most system functions are evaluated once *per query*.

      As you might realize, this can cause confusion and unexpected results. I suggest you pass the value

      in to the function through a parameters instead.

      You can create a view with GETDATE() and let your function get the value through the view, but think

      hard before doing this so it doesn't introduce grief for you...

      --

      Tibor Karaszi, SQL Server MVP

      http://www.karaszi.com/sqlserver/default.asp

      http://www.solidqualitylearning.com/

      "SubramanianRamesh" <SubramanianRamesh.sql.todaysummary.com.discussions.microsoft.com> wrote in message

      news:C110CE54-EA25-4BB9-928B-2E607B4BEB4A.sql.todaysummary.com.microsoft.com...

      > hai,

      > simlpe question

      > how to use getdate() funtion in userdefined functions ,if i am trying to use

      > this function , improper use of getdate () function

      >

      > thanks in advance

      #1; Thu, 29 May 2008 03:42:00 GMT
    • you can't call nondeterministic system functions (such as getdate())

      from UDFs

      SubramanianRamesh wrote:

      > hai,

      > simlpe question

      > how to use getdate() funtion in userdefined functions ,if i am trying to use

      > this function , improper use of getdate () function

      >

      > thanks in advance

      #2; Thu, 29 May 2008 03:43:00 GMT