Cómo no hacer nada en SQL Server [duplicar]
Posible Duplicado:
Instrucción vacía en T-SQL
¿Cómo puedo hacer que esto se compile en SQL Server?
IF @value IS NULL
BEGIN
-- I don't want to do anything here
END
6 answers
¿Quieres decir que falla debido al PRINCIPIO-FIN vacío? haga algo sin sentido pero sintácticamente válido si por alguna razón no puede eliminar el bloque;
IF @value IS NULL
BEGIN
set @value=@value -- or print 'TODO' etc
END
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
2011-08-05 09:45:00
Basado en la idea de este hilo :
IF @value IS NULL
BEGIN
WAITFOR DELAY '00:00:00'
END
Debe tenerse en cuenta (no sabía al principio) que, al igual que la IMPRESIÓN, este método no es universal. En particular, no se puede utilizar en funciones. Utilice otras sugerencias cuando necesite agregar un NO-OP en algún lugar de una función.
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
2013-06-13 07:18:45
Mi primera respuesta.
IF @value IS NULL BEGIN
goto a a:
END
Segunda respuesta después de pensar un poco
IF @value IS NULL BEGIN
SET
END
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
2011-08-05 15:54:12
IF @value IS NULL
BEGIN
-- I don't want to do anything here
Print 'What a waste of time'
END
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
2011-08-05 14:58:00
Las únicas cosas en las que puedo pensar son operaciones que son muy rápidas y no afectan al disco. Las más fáciles y rápidas son probablemente las declaraciones y asignaciones de variables...
DECLARE @t int
O
SET @t=@t
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
2011-08-07 11:23:22
La pregunta en mi mente es: ¿por qué pondrías eso en tu código? Si la razón es que tiene un bloque else, cambie la condición a "if @value is not null". Sin embargo, por sí solo, este bloque no hace nada.
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
2011-08-05 11:05:22