Possible Duplicate:
Empty statement in T-SQL
How can I get this to compile in SQL Server?
IF @value IS NULL BEGIN -- I don't want to do anything here END
The go to solution for removing duplicate rows from your result sets is to include the distinct keyword in your select statement. It tells the query engine to remove duplicates to produce a result set in which every row is unique.
The NULL statement is an executable statement that does nothing. The NULL statement can act as a placeholder whenever an executable statement is required, but no SQL operation is wanted; for example, within a branch of the IF-THEN-ELSE statement.
EXCEPT automatically removes all duplicates in the final result, whereas NOT IN retains duplicate tuples. It is also important to note that EXCEPT is not supported by MySQL.
To select duplicate values, you need to create groups of rows with the same values and then select the groups with counts greater than one. You can achieve that by using GROUP BY and a HAVING clause.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With