Using SQL Server - which is the fastest or best practice method to use for date retrieval? Is there a difference?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
- How can I convert a OLE Automation Date value to a
My vote is for
CURRENT_TIMESTAMP
for 'portability' reasons i.e. why be SQL Server -specific when there is a direct SQL-92 equivalent?PS why was it not named
getdatetime()
? Now that SQL Server 2008 has aDATE
andTIME
data type, we can hope to get support for SQL-92'sCURRENT_DATE
andCURRENT_TIME
, at which pointgetdate()
could be potentially even more confusing.Books Online tells us that CURRENT_TIMESTAMP "is equivalent to GETDATE()".
CURRENT_TIMESTAMP is part of the ANSI SQL spec. GETDATE() is a SQL Server-specific function inherited from the original Sybase code on which SQL Server is based.
They do exactly the same thing, though.
CURRENT_TIMESTAMP is standard ANSI SQL, and so is theoretically one tiny little island of 'don't need to change' amongst your thousands of SQL Server-specific lines of SQL if you ever need to move databases....