Possible Duplicate:
Empty statement in T-SQL
How can I get this to compile in SQL Server?
开发者_JS百科IF @value IS NULL
BEGIN
-- I don't want to do anything here
END
You mean it fails because of the empty BEGIN-END? do something meaningless but syntactically valid if for some reason you cant remove the block;
IF @value IS NULL
BEGIN
set @value=@value -- or print 'TODO' etc
END
Based on the idea from this thread:
IF @value IS NULL
BEGIN
WAITFOR DELAY '00:00:00'
END
Should be noted (didn't know at first) that, like PRINT, this method is not universal. In particular, it cannot be used in functions. Use other suggestions when you need to add a NO-OP somewhere in a function.
My first answer.
IF @value IS NULL BEGIN
goto a a:
END
Second answer after thinking a bit
IF @value IS NULL BEGIN
SET
END
IF @value IS NULL
BEGIN
-- I don't want to do anything here
Print 'What a waste of time'
END
The only things I can think of are operations that are very fast and don't affect disk. The easiest and fastest are probably variable declarations and assignments...
DECLARE @t int
OR
SET @t=@t
The question in my mind is: why would you put that in your code? If the reason is that you have an else block, then flip the condition to "if @value is not null". By itself though, this block doesn't do anything.
精彩评论