/ Published in: SQL
                    
                                        
To start my new post area I will share a simple stored procedure that will check if a record exists, if so update it, otherwise create it; Simple hum?! Just Update it to your needs :)
                
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
IF (SELECT COUNT(*) FROM YourTable WHERE YourVar = @YourValue) = 0
BEGIN
INSERT INTO YourTable(YourVar) VALUES(@YourVar)
END
ELSE
BEGIN
UPDATE YourTable
SET YourVar = @YourValue
WHERE YourVar = @YourValue
END
URL: http://www.digitalwks.com/blogs/diogo-raminhos/sql-series-insertupdate-in-one-stored-procedure/
Comments
 Subscribe to comments
                    Subscribe to comments
                
                