|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
GetDate inside a FunctionHi,
I tried to use GetDate inside a SQL server 2000 user defined function and got error: Invalid use of GetDate within a function Here is my code snippet: DECLARE @Today smallDateTime SET @Today = GetDate() What should I do? TIA GETDATE() is nondeterinistic and, thus, cannot be used in a function. You
can, however, create a view and use it: create view Now as select getdate () RightNow go -- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA SQL Server MVP Columnist, SQL Server Professional Toronto, ON Canada www.pinpub.com "John" <some***@microsoft.com> wrote in message I tried to use GetDate inside a SQL server 2000 user defined function andnews:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... Hi, got error: Invalid use of GetDate within a function Here is my code snippet: DECLARE @Today smallDateTime SET @Today = GetDate() What should I do? TIA do this
declare @date datetime select @date =max(last_bitch) from master.dbo.sysprocesses -- Show quoteHilary Cotter Looking for a SQL Server replication book? http://www.nwsu.com/0974973602.html Looking for a FAQ on Indexing Services/SQL FTS http://www.indexserverfaq.com "John" <some***@microsoft.com> wrote in message news:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... > Hi, > > I tried to use GetDate inside a SQL server 2000 user defined function and > got error: > > Invalid use of GetDate within a function > > Here is my code snippet: > > DECLARE @Today smallDateTime > SET @Today = GetDate() > > What should I do? > > TIA > oops sorry, nasty typo there
declare @date datetime select @date =max(last_bAtch) from sysprocesses -- Show quoteHilary Cotter Looking for a SQL Server replication book? http://www.nwsu.com/0974973602.html Looking for a FAQ on Indexing Services/SQL FTS http://www.indexserverfaq.com "John" <some***@microsoft.com> wrote in message news:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... > Hi, > > I tried to use GetDate inside a SQL server 2000 user defined function and > got error: > > Invalid use of GetDate within a function > > Here is my code snippet: > > DECLARE @Today smallDateTime > SET @Today = GetDate() > > What should I do? > > TIA > I was wondering if maybe the developer was having a bad day with the
wife/mother-in-law when he designed the Last_Bitch column <grin> Show quote "Hilary Cotter" <hilary.cot***@gmail.com> wrote in message news:uPsQ4jWHGHA.3728@tk2msftngp13.phx.gbl... > oops sorry, nasty typo there > > > declare @date datetime > select @date =max(last_bAtch) from sysprocesses > > -- > Hilary Cotter > Looking for a SQL Server replication book? > http://www.nwsu.com/0974973602.html > > Looking for a FAQ on Indexing Services/SQL FTS > http://www.indexserverfaq.com > > "John" <some***@microsoft.com> wrote in message > news:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... >> Hi, >> >> I tried to use GetDate inside a SQL server 2000 user defined function and >> got error: >> >> Invalid use of GetDate within a function >> >> Here is my code snippet: >> >> DECLARE @Today smallDateTime >> SET @Today = GetDate() >> >> What should I do? >> >> TIA >> > > ROFL!
I must admit, it was the very first thing that caught my eye when I glanced at Hilary's code snippet. Great Freudian slip there Hilary! Show quote >I was wondering if maybe the developer was having a bad day with the >wife/mother-in-law when he designed the Last_Bitch column <grin> > >"Hilary Cotter" <hilary.cot***@gmail.com> wrote in message >news:uPsQ4jWHGHA.3728@tk2msftngp13.phx.gbl... > > >>oops sorry, nasty typo there >> >> >>declare @date datetime >>select @date =max(last_bAtch) from sysprocesses >> >>-- >>Hilary Cotter >>Looking for a SQL Server replication book? >>http://www.nwsu.com/0974973602.html >> >>Looking for a FAQ on Indexing Services/SQL FTS >>http://www.indexserverfaq.com >> >>"John" <some***@microsoft.com> wrote in message >>news:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... >> >> >>>Hi, >>> >>>I tried to use GetDate inside a SQL server 2000 user defined function and >>>got error: >>> >>>Invalid use of GetDate within a function >>> >>>Here is my code snippet: >>> >>>DECLARE @Today smallDateTime >>>SET @Today = GetDate() >>> >>>What should I do? >>> >>>TIA >>> >>> >>> >> >> > > > > Thanks for pointing that out. Needed a good laugh in the morning. :-)
-- Show quoteTibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ Blog: http://solidqualitylearning.com/blogs/tibor/ "Dave Frommer" <anti@spam.com> wrote in message news:eQaWLxWHGHA.1028@TK2MSFTNGP11.phx.gbl... >I was wondering if maybe the developer was having a bad day with the > wife/mother-in-law when he designed the Last_Bitch column <grin> >
Show quote
:-))))))))))))))))
"Dave Frommer" <anti@spam.com> wrote in message news:eQaWLxWHGHA.1028@TK2MSFTNGP11.phx.gbl... >I was wondering if maybe the developer was having a bad day with the >wife/mother-in-law when he designed the Last_Bitch column <grin> > > "Hilary Cotter" <hilary.cot***@gmail.com> wrote in message > news:uPsQ4jWHGHA.3728@tk2msftngp13.phx.gbl... >> oops sorry, nasty typo there >> >> >> declare @date datetime >> select @date =max(last_bAtch) from sysprocesses >> >> -- >> Hilary Cotter >> Looking for a SQL Server replication book? >> http://www.nwsu.com/0974973602.html >> >> Looking for a FAQ on Indexing Services/SQL FTS >> http://www.indexserverfaq.com >> >> "John" <some***@microsoft.com> wrote in message >> news:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... >>> Hi, >>> >>> I tried to use GetDate inside a SQL server 2000 user defined function >>> and got error: >>> >>> Invalid use of GetDate within a function >>> >>> Here is my code snippet: >>> >>> DECLARE @Today smallDateTime >>> SET @Today = GetDate() >>> >>> What should I do? >>> >>> TIA >>> >> >> > > The mask has slipped... ;-)
-- Tom ---------------------------------------------------- Thomas A. Moreau, BSc, PhD, MCSE, MCDBA SQL Server MVP Columnist, SQL Server Professional Toronto, ON Canada www.pinpub.com .. "Hilary Cotter" <hilary.cot***@gmail.com> wrote in message oops sorry, nasty typo therenews:uPsQ4jWHGHA.3728@tk2msftngp13.phx.gbl... declare @date datetime select @date =max(last_bAtch) from sysprocesses -- Show quoteHilary Cotter Looking for a SQL Server replication book? http://www.nwsu.com/0974973602.html Looking for a FAQ on Indexing Services/SQL FTS http://www.indexserverfaq.com "John" <some***@microsoft.com> wrote in message news:e6ZConVHGHA.532@TK2MSFTNGP15.phx.gbl... > Hi, > > I tried to use GetDate inside a SQL server 2000 user defined function and > got error: > > Invalid use of GetDate within a function > > Here is my code snippet: > > DECLARE @Today smallDateTime > SET @Today = GetDate() > > What should I do? > > TIA > Of all solutions mentioned in other post (with the exception of the "b*tch"
discussion) the fastest would be to simply supply the current datetime as a parameter. ML --- http://milambda.blogspot.com/ |
|||||||||||||||||||||||