How to use Getdate() in sql server function_PHP tutorial

WBOY
Release: 2016-07-13 17:03:42
Original
1176 people have browsed it

create view v_getdate
as
select getdate() [output]
go
-------------------------- -------------------------------------
create function f_getdate()
returns datetime
as
begin
declare @n datetime
select @n = output from v_getdate
return(@n)
end
go
------ -------------------------------------------------- -------
Call: select dbo.f_getdate()
============================== =========================================
-----Below It is parsed--
should be used inside function and is not allowed to be used.
Functions can be deterministic or indeterminate. Functions are deterministic if they always return the same result whenever they are called with a specific set of input values. Functions are nondeterministic if the results returned are different each time they are called, even with the same specific set of input values.
Uncertain functions can have side effects. A side effect is to change some global state of the database, like updating a database table or some external resource like a file or network, etc. (for example, modifying a file or sending an email message).
Building non-deterministic functions into the body of a user-defined function is not allowed; these non-deterministic functions are as follows:
@@CONNECTIONS @@TOTAL_ERRORS
@@CPU_BUSY @@TOTAL_READ
@@IDLE @@TOTAL_WRITE
@@IO_BUSY GETDATE
@@MAX_CONNECTIONS GETUTCDATE
@@PACK_RECEIVED NEWID
@@PACK_SENT RAND
@@PACKET_ERRORS TEXTPTR
@@TIMETICKS
Although in the user-defined function body Indeterminate functions are not allowed; these user-defined functions can still produce side effects when calling extended stored procedures.
Since extended stored procedures can have side effects on the database, calling functions of extended stored procedures is undefined. When a user-defined function calls an extended stored procedure that has side effects on the database, do not expect the result set to be consistent or to execute the function.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630947.htmlTechArticlecreate view v_getdate as select getdate() [output] go ------------ -------------------------------------------------- - create function f_getdate() returns datetime as begin declare @...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template