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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Store Procedure Help

Author  Topic 

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-07-27 : 17:24:27
Hi guys,

I want to run Job and during job i want to say, If Status is 1 run StoreProcedure1 and if Status is 2 run StoreProcedure2. Please how i can right sql query.

Thanks.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-27 : 17:25:55
Where is the value of status coming from?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-07-27 : 17:27:04
Database
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-27 : 17:37:20
Need more information...Please help us help you.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-07-27 : 17:40:50
I have table in SQl, I want to run a job every 5 minutes. in job i want to use this sql script to say
or could you please check this sql syntax gonna work

WHILE(1=1)
begin

If exists (select Distinct id from sales where Status = '1')
Begin
exec store_Proceudre 1
end
else
exec store_Procedure2
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-27 : 17:46:05
the syntax looks fine. but can you tell whats the purpose of this?

also for exists check you dont need distinct id inside. just select 1 is enough

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-27 : 17:47:48
Use SELECT * for EXISTS.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Sonu619
Posting Yak Master

202 Posts

Posted - 2012-07-27 : 17:49:28
After i run this syntax keep looping and populating table.. This syntax should run only once and first one because i have only status = 1. Help me out ASAP.
Thank You.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-07-27 : 17:52:15
The code you posted is not looping. I don't think you're telling us the full story.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -