Function for Using Now instead of GetDate in SQL Server 2012 -


i use now() current date , time, trying create function, cannot syntax right

use [db1] go  set ansi_nulls on go set quoted_identifier on go create function [dbo].[now]() returns [date]  begin  declare @now1  select getdate()                      -- return result of function     return @now1 end 

any appreciated.

you don't need create own function current date, can use

 select  getdate()   

just kidding :) imagine want more returning current date

type body way:

declare @now1 datetime select  @now1 = getdate()    

so full code should be

use [db1] go  set ansi_nulls on go set quoted_identifier on go create function [dbo].[now]() returns [datetime]  begin     declare @now1 datetime     select  @now1 = getdate()            return @now1 end 

Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -