Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Constanly Running SQL Sproc Expand / Collapse
Author
Message
Posted Sunday, January 2, 2011 12:15 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 25, 2014 3:40 PM
Points: 309, Visits: 729
I have an Azure DB. As we all know, that means no SQL Agent. I need to have a background task that runs every few minutes to clean up some things. Since I can't setup an Agent job, I was thinking about a sproc with an infinite loop. That does some work every 5 min. (or whatever). The alternative is an Azure web role. That's probably a better solution, but it's also much more expensive.

Any thoughts on the infinite loop thing? Is there any way to "sleep" in a sproc?


.
Post #1041653
Posted Sunday, January 2, 2011 3:17 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 3:14 PM
Points: 4,363, Visits: 9,545
Not sure about Azure and what is available or not - but lookup WAITFOR in BOL. That will allow your process to sleep for a time and start up again.



Jeffrey Williams
Problems are opportunites brilliantly disguised as insurmountable obstacles.

How to post questions to get better answers faster
Managing Transaction Logs
Post #1041667
Posted Sunday, January 2, 2011 3:26 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 25, 2014 3:40 PM
Points: 309, Visits: 729
Perfect, that looks like exactly what I need. The fact that it exists must mean that it's not THAT bad an idea. :)

Thanks!


.
Post #1041672
Posted Sunday, January 2, 2011 4:06 PM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Thursday, September 25, 2014 3:40 PM
Points: 309, Visits: 729
Although, I guess I'm still stuck with the same basic problem. How do I start the sproc? Without a SQL Agent, I don't have a way to kick it off.

Anybody know of a way to automatically start a sproc at SQL Server startup?


.
Post #1041674
Posted Sunday, January 2, 2011 5:12 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 12:52 PM
Points: 1,805, Visits: 5,869
According to Books Online, SQL Azure does not support sp_procoption which is what you would use to have an auto-execute SP.

Perhaps you could have a scheduled task on a local server that runs the stored proc?


MM


  • MMGrid Addin
  • MMNose Addin


  • Forum Etiquette: How to post Reporting Services problems
  • Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
  • How to Post Performance Problems - by Gail Shaw

  • Post #1041678
    Posted Sunday, January 2, 2011 5:47 PM
    Old Hand

    Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

    Group: General Forum Members
    Last Login: Thursday, September 25, 2014 3:40 PM
    Points: 309, Visits: 729
    Thanks MM.

    Bit by Azure again. Man, I really need to talk my company off SQL Azure. It is just too limited right now. Anyone out there looking to move to Azure, DON'T DO IT if your app depends on ANYTHING other than DML, DDL. It's just not there yet.

    The local server -> Azure server is a thought. Probably ought to just stick with a basic solution and create a web role I guess. Thanks for the help all!


    .
    Post #1041683
    Posted Monday, January 3, 2011 6:34 AM


    SSChampion

    SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

    Group: General Forum Members
    Last Login: Today @ 11:01 AM
    Points: 14,029, Visits: 28,404
    BSavoie (1/2/2011)
    Perfect, that looks like exactly what I need. The fact that it exists must mean that it's not THAT bad an idea. :)

    Thanks!


    Just be careful about transactions & locking. A proc running in an infinite loop is going to hold stuff open pretty much infinitely.


    ----------------------------------------------------
    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
    The Scary DBA
    Author of: SQL Server Query Performance Tuning
    SQL Server 2012 Query Performance Tuning
    SQL Server 2008 Query Performance Tuning Distilled
    and
    SQL Server Execution Plans

    Product Evangelist for Red Gate Software
    Post #1041810
    Posted Monday, January 3, 2011 8:09 AM
    Forum Newbie

    Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

    Group: General Forum Members
    Last Login: Monday, January 28, 2013 3:30 AM
    Points: 2, Visits: 38
    In Microsoft documentation http://msdn.microsoft.com/en-us/library/ee336245.aspx#sqlagent say:

    SQL Server Agent/Jobs

    SQL Azure Database does not support SQL Server Agent or jobs. You can, however, run SQL Server Agent on your on-premise SQL Server and connect to SQL Azure Database.

    Danilo
    Post #1041848
    Posted Monday, January 3, 2011 7:20 PM
    Old Hand

    Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

    Group: General Forum Members
    Last Login: Thursday, September 25, 2014 3:40 PM
    Points: 309, Visits: 729
    I suppose the on premis SQL Agent is as good as anything. I'm sure I'll find other uses for that scenario anyway. Thanks!

    .
    Post #1042121
    Posted Monday, January 10, 2011 6:47 PM


    SSC Rookie

    SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

    Group: General Forum Members
    Last Login: Friday, October 24, 2014 6:58 AM
    Points: 30, Visits: 176
    If you're looking for background functionality, you should be looking at using an Azure Compute instance to kick this off instead of running it in the storage layer. You have to think of the entire Azure platform as a bunch of separate pieces of functionality that fit together to give you a complete solution.

    Jeremiah Peschka
    Microsoft SQL Server MVP
    Managing Director - Brent Ozar PLF, LLC
    Post #1045655
    « Prev Topic | Next Topic »

    Add to briefcase 12»»

    Permissions Expand / Collapse