Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do nothing in SQL Server [duplicate]

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 
like image 784
satnhak Avatar asked Aug 05 '11 09:08

satnhak


People also ask

How do I ensure no duplicates in SQL?

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.

How do I know if I have SQL do nothing?

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.

Does except SQL remove duplicates?

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.

How do I duplicate a row in SQL?

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.


1 Answers

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 
like image 137
Alex K. Avatar answered Sep 29 '22 00:09

Alex K.