DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to implement SQL NOW() functionality with GETDATE()?

Execute the following Microsoft SQL Server T-SQL programming script in SSMS Query Editor to demonstrate the SQL NOW equivalent functions.

-- SQL NOW() function: Current date & time - T-SQL equivalent: getdate()

SELECT TOP (5) ProductID, ProductName=Name, ListPrice,

               GETDATE() as PerDate

FROM AdventureWorks2008.Production.Product

WHERE ListPrice > 0.0

ORDER BY NEWID()

/*

ProductID   ProductName             ListPrice   PerDate

847   Headlights - Dual-Beam        34.99       2016-07-01 07:14:32.393

984   Mountain-500 Silver, 40       564.99      2016-07-01 07:14:32.393

837   HL Road Frame - Black, 62     1431.50     2016-07-01 07:14:32.393

880   Hydration Pack - 70 oz.       54.99       2016-07-01 07:14:32.393

724   LL Road Frame - Black, 62     337.22      2016-07-01 07:14:32.393

*/

 

-- SQL NOW() function - ANSI SQL equivalent: CURRENT_TIMESTAMP

SELECT TOP (3) ProductID, ProductName=Name, ListPrice,

               CURRENT_TIMESTAMP as PerDate

FROM AdventureWorks2008.Production.Product

WHERE ListPrice > 0.0

ORDER BY NEWID()

/*

ProductID   ProductName             ListPrice   PerDate

763   Road-650 Red, 48              782.99      2016-07-01 07:15:40.120

794   Road-250 Black, 48            2443.35     2016-07-01 07:15:40.120

836   ML Road Frame-W - Yellow, 48  594.83      2016-07-01 07:15:40.120

*/

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE