Recuperación de la fecha en sql server, MARCA DE TIEMPO ACTUAL vs GetDate()


Usando SQL Server - ¿cuál es el método más rápido o de mejor práctica a utilizar para la recuperación de fechas? ¿Hay alguna diferencia?

Author: Mark Schultheiss, 2008-10-09

4 answers

CURRENT_TIMESTAMP es estándar ANSI SQL, y también lo es teóricamente una pequeña isla de 'no necesita cambiar' entre sus miles de líneas de SQL específicas de SQL Server si alguna vez necesita mover bases de datos....

 87
Author: Cowan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 09:52:15

CURRENT_TIMESTAMP es parte de la especificación SQL de ANSI. GETDATE() es una función específica de SQL Server heredada del código original de Sybase en el que se basa SQL Server.

Hacen exactamente lo mismo, sin embargo.

 30
Author: Dylan Beattie,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 09:52:56

Mi voto es para CURRENT_TIMESTAMP por razones de 'portabilidad', es decir, ¿por qué ser específico de SQL Server cuando hay un equivalente directo de SQL-92?

PS por qué no fue nombrado getdatetime()? Ahora que SQL Server 2008 tiene un tipo de datos DATE y TIME, podemos esperar obtener soporte para los CURRENT_DATE y CURRENT_TIME de SQL-92, momento en el que getdate() podría ser potencialmente aún más confuso.

 10
Author: onedaywhen,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 11:11:12

Books Online nos dice que CURRENT_TIMESTAMP "es equivalente a GETDATE()".

 8
Author: ila,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2008-10-09 09:50:33