Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Run Procedure (IF)

Author  Topic 

Amber_Deslaurier
Starting Member

40 Posts

Posted - 2010-06-19 : 21:42:53
Hi

I need code to run a simple procedure that excute code after it checks the table to ensure the date in the query is different from the date in the column... this way it wont be duplicate data.

Thanks, Amber

Sachin.Nand

2937 Posts

Posted - 2010-06-20 : 04:31:29
Try if exists.
Something like this.
if exists(select * from yourtable where date='yourdate')
dosomething
else
dosomethingelse


Limitations live only in our minds. But if we use our imaginations, our possibilities become limitless.

PBUH
Go to Top of Page

dattatreysindol
Starting Member

20 Posts

Posted - 2010-06-20 : 04:32:18
Hi There -

What is your requirement exactly ?

If you just want to run a piece of code based on a certain condition, then you can use IF / ELSE clause available in T-SQL to check and execute the code to update the table based on whether the data in the query is different from the data in the column.

Hope it helps!


Dattatrey Sindol
http://mytechnobook.blogspot.com/

This information is provided "AS IS" with no warranties, and confers no rights.
Go to Top of Page
   

- Advertisement -