Can you use GETDATE() function in MSSQL2K, MSSQL2K5, and MSSQL2K8?
Which MSSQL version of the following function definition will generate an error?
CREATE FUNCTION [dbo].[fnCheckDate] ()
RETURNS DATETIME
AS
BEGIN
DECLARE @Today DATETIME
SET @Today = GETDATE()
SET @Today = DATEADD(DD, DATEDIFF(DD, 0, @Today), 0)
RETURN DATEADD(DD, 1, @Today)
END
A. SQL Server 2000
B. SQL Server 2005
C. SQL Server 2008
D. No error is generated. The function will be created for all versions.
E. Error will be generated for all versions.
Answer:[A]
Explanation:The GETDATE() function, and any non-deterministic functions, are not allowed in a user-defined function of SQL Server 2000.
Highlight to find out the answer.
Monday, February 15, 2010
Using GETDATE in function?
at 6:01 PM
Labels: SQL Server, SQL Server Test, SQL Server Tip
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment