Welcome Guest Search | Active Topics | Members | Log In | Register

Run script on Instance Startup Options · View
traceable1
Posted: Thursday, October 18, 2007 3:49:55 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 18/10/2007 15:49:55
Date: Thu, 18 Oct 2007 15:49:55 -0000


Is there a way I can set up a SQL script to run when the instance
starts up?
SQL Server 2005 SP2

thanks!

Tibor Karaszi
Posted: Thursday, October 18, 2007 7:58:37 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 18/10/2007 19:58:37
Date: Thu, 18 Oct 2007 17:58:37 +0200

Put it in a stored procedure and mark the proc as an autostart proc (sp_procoption).

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


"traceable1" <thhamlin@gmail.com> wrote in message
news:1192722595.538697.92480@y27g2000pre.googlegroups.com...
>
> Is there a way I can set up a SQL script to run when the instance
> starts up?
> SQL Server 2005 SP2
>
> thanks!
>

traceable1
Posted: Thursday, October 18, 2007 8:34:43 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 18/10/2007 20:34:43
Date: Thu, 18 Oct 2007 20:34:43 -0000


Thank you so much for your feedback!

So how exactly would I set up the script to run when the Agent starts?






On Oct 18, 1:27 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@hotmail.nomail.com> wrote:
> Actually, one can claim that your alternative, Ekrem, is a cleaner soluti=
on than mine. I.e., it
> might feel better to have a client app (Agent) execute whatever TSQL comm=
ands you want to run
> instead of the database engine. (Of course, if one only start the engine =
and not Agent, then the
> script will not be executed.)
>
> Good thinking. :-)
>
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asp=
http://sqlblog.com/blogs/tibor_karaszi
>
> "Ekrem =D6nsoy" <ek...@btegitim.com> wrote in message
>
> news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@microsoft.com...
>
>
>
> > Alternatively you can create a job to run your stuff which starts when =
SQL Server Agent starts...
> > (may not be as good as Tibor's suggestion :) but I already said, it's j=
ust an alternative)
>
> > --
> > Ekrem =D6nsoy
>
> > "traceable1" <thham...@gmail.com> wrote in message
> >news:1192722595.538697.92480@y27g2000pre.googlegroups.com...
>
> >> Is there a way I can set up a SQL script to run when the instance
> >> starts up?
> >> SQL Server 2005 SP2
>
> >> thanks!- Hide quoted text -
>
> - Show quoted text -


traceable1
Posted: Thursday, October 18, 2007 9:10:19 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 18/10/2007 21:10:19
Date: Thu, 18 Oct 2007 21:10:19 -0000



Excellent! Thank ya'll so much!!



On Oct 18, 3:59 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@hotmail.nomail.com> wrote:
> Create an Agent job with one or several job steps containing your TSQL (o=
r whatever) code. Schedule
> this job to be executed when Agent starts.
>
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asp=
http://sqlblog.com/blogs/tibor_karaszi
>
> "traceable1" <thham...@gmail.com> wrote in message
>
> news:1192739683.702442.18160@k35g2000prh.googlegroups.com...
>
> Thank you so much for your feedback!
>
> So how exactly would I set up the script to run when the Agent starts?
>
> On Oct 18, 1:27 pm, "Tibor Karaszi"
>
>
>
> <tibor_please.no.email_kara...@hotmail.nomail.com> wrote:
> > Actually, one can claim that your alternative, Ekrem, is a cleaner solu=
tion than mine. I.e., it
> > might feel better to have a client app (Agent) execute whatever TSQL co=
mmands you want to run
> > instead of the database engine. (Of course, if one only start the engin=
e and not Agent, then the
> > script will not be executed.)
>
> > Good thinking. :-)
>
> > --
> > Tibor Karaszi, SQL Server
> > MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs=
/=2E..
>
> > "Ekrem =D6nsoy" <ek...@btegitim.com> wrote in message
>
> >news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@microsoft.com...
>
> > > Alternatively you can create a job to run your stuff which starts whe=
n SQL Server Agent
> > > starts...
> > > (may not be as good as Tibor's suggestion :) but I already said, it's=
just an alternative)
>
> > > --
> > > Ekrem =D6nsoy
>
> > > "traceable1" <thham...@gmail.com> wrote in message
> > >news:1192722595.538697.92480@y27g2000pre.googlegroups.com...
>
> > >> Is there a way I can set up a SQL script to run when the instance
> > >> starts up?
> > >> SQL Server 2005 SP2
>
> > >> thanks!- Hide quoted text -
>
> > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -


Tibor Karaszi
Posted: Thursday, October 18, 2007 10:27:45 PM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 18/10/2007 22:27:45
Date: Thu, 18 Oct 2007 20:27:45 +0200

Actually, one can claim that your alternative, Ekrem, is a cleaner solution than mine. I.e., it
might feel better to have a client app (Agent) execute whatever TSQL commands you want to run
instead of the database engine. (Of course, if one only start the engine and not Agent, then the
script will not be executed.)

Good thinking. :-)

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


"Ekrem Önsoy" <ekrem@btegitim.com> wrote in message
news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@microsoft.com...
> Alternatively you can create a job to run your stuff which starts when SQL Server Agent starts...
> (may not be as good as Tibor's suggestion :) but I already said, it's just an alternative)
>
> --
> Ekrem Önsoy
>
>
>
> "traceable1" <thhamlin@gmail.com> wrote in message
> news:1192722595.538697.92480@y27g2000pre.googlegroups.com...
>>
>> Is there a way I can set up a SQL script to run when the instance
>> starts up?
>> SQL Server 2005 SP2
>>
>> thanks!
>>
>

Tibor Karaszi
Posted: Friday, October 19, 2007 12:59:38 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 19/10/2007 00:59:38
Date: Thu, 18 Oct 2007 22:59:38 +0200

Create an Agent job with one or several job steps containing your TSQL (or whatever) code. Schedule
this job to be executed when Agent starts.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


"traceable1" <thhamlin@gmail.com> wrote in message
news:1192739683.702442.18160@k35g2000prh.googlegroups.com...

Thank you so much for your feedback!

So how exactly would I set up the script to run when the Agent starts?






On Oct 18, 1:27 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@hotmail.nomail.com> wrote:
> Actually, one can claim that your alternative, Ekrem, is a cleaner solution than mine. I.e., it
> might feel better to have a client app (Agent) execute whatever TSQL commands you want to run
> instead of the database engine. (Of course, if one only start the engine and not Agent, then the
> script will not be executed.)
>
> Good thinking. :-)
>
> --
> Tibor Karaszi, SQL Server
> MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
>
> "Ekrem Önsoy" <ek...@btegitim.com> wrote in message
>
> news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@microsoft.com...
>
>
>
> > Alternatively you can create a job to run your stuff which starts when SQL Server Agent
> > starts...
> > (may not be as good as Tibor's suggestion :) but I already said, it's just an alternative)
>
> > --
> > Ekrem Önsoy
>
> > "traceable1" <thham...@gmail.com> wrote in message
> >news:1192722595.538697.92480@y27g2000pre.googlegroups.com...
>
> >> Is there a way I can set up a SQL script to run when the instance
> >> starts up?
> >> SQL Server 2005 SP2
>
> >> thanks!- Hide quoted text -
>
> - Show quoted text -


Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.133 seconds.