Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to use If...Else in SQL Server2000 with select and insert statements??
Posted
Comments
LaxmikantYadav 31-Oct-11 8:46am    
Not Cleared :( . Can u explain more.

1 solution

You can do something like:

SQL
IF EXISTS (SELECT 1 FROM Table_name WHERE data_field  = '')  
BEGIN    
   SELECT TableID FROM Table_name WHERE data_field = '' 
END 
ELSE 
BEGIN    
   INSERT INTO Table_name (data_field) VALUES('') 
END
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900