SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Store Procedure Help
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Sonu619
Posting Yak Master

193 Posts

Posted - 07/27/2012 :  17:24:27  Show Profile  Reply with Quote
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

USA
35007 Posts

Posted - 07/27/2012 :  17:25:55  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

193 Posts

Posted - 07/27/2012 :  17:27:04  Show Profile  Reply with Quote
Database
Go to Top of Page

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 07/27/2012 :  17:37:20  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

193 Posts

Posted - 07/27/2012 :  17:40:50  Show Profile  Reply with Quote
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

India
47040 Posts

Posted - 07/27/2012 :  17:46:05  Show Profile  Reply with Quote
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

USA
35007 Posts

Posted - 07/27/2012 :  17:47:48  Show Profile  Visit tkizer's Homepage  Reply with Quote
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

193 Posts

Posted - 07/27/2012 :  17:49:28  Show Profile  Reply with Quote
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

USA
35007 Posts

Posted - 07/27/2012 :  17:52:15  Show Profile  Visit tkizer's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000