Re: Run SQL script on Instance Startup





Tibor Karaszi View profile
More options Oct 18, 10:58 am

Newsgroups: microsoft.public.sqlserver.server
From: "Tibor Karaszi"
<tibor_please.no.email_kara...@xxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Oct 2007 17:58:37 +0200
Local: Thurs, Oct 18 2007 10:58 am
Subject: Re: Run script on Instance Startup
Reply | Reply to author | Forward | Print | Individual message | Show
original | Report this message | Find messages by this author
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" <thham...@xxxxxxxxx> wrote in message


news:1192722595.538697.92480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


- Hide quoted text -
- Show quoted text -

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


thanks!





Reply Reply to author Forward Rate this post: Text
for clearing space







You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before
posting.
You do not have the permission required to post.



Tibor Karaszi View profile
More options Oct 18, 1:27 pm

Newsgroups: microsoft.public.sqlserver.server
From: "Tibor Karaszi"
<tibor_please.no.email_kara...@xxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Oct 2007 20:27:45 +0200
Local: Thurs, Oct 18 2007 1:27 pm
Subject: Re: Run script on Instance Startup
Reply | Reply to author | Forward | Print | Individual message | Show
original | Report this message | Find messages by this author
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" <ek...@xxxxxxxxxxxx> wrote in message


news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@xxxxxxxxxxxxxxxx


- Hide quoted text -
- Show quoted text -

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...@xxxxxxxxx> wrote in message
news:1192722595.538697.92480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


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


thanks!





Reply Reply to author Forward Rate this post: Text
for clearing space







You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before
posting.
You do not have the permission required to post.



traceable1 View profile
More options Oct 18, 3:34 pm

Newsgroups: microsoft.public.sqlserver.server
From: traceable1 <thham...@xxxxxxxxx>
Date: Thu, 18 Oct 2007 20:34:43 -0000
Local: Thurs, Oct 18 2007 3:34 pm
Subject: Re: Run script on Instance Startup
Reply | Reply to author | Forward | Print | Individual message | Show
original | Remove | Report this message | Find messages by this
author
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"



- Hide quoted text -
- Show quoted text -

<tibor_please.no.email_kara...@xxxxxxxxxxxxxxxxxx> 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/...


"Ekrem Önsoy" <ek...@xxxxxxxxxxxx> wrote in message


news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@xxxxxxxxxxxxxxxx


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...@xxxxxxxxx> wrote in message
news:1192722595.538697.92480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


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 -





Reply Reply to author Forward







You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before
posting.
You do not have the permission required to post.



Tibor Karaszi View profile
More options Oct 18, 3:59 pm

Newsgroups: microsoft.public.sqlserver.server
From: "Tibor Karaszi"
<tibor_please.no.email_kara...@xxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Oct 2007 22:59:38 +0200
Local: Thurs, Oct 18 2007 3:59 pm
Subject: Re: Run script on Instance Startup
Reply | Reply to author | Forward | Print | Individual message | Show
original | Report this message | Find messages by this author
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" <thham...@xxxxxxxxx> wrote in message


news:1192739683.702442.18160@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

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"



- Hide quoted text -
- Show quoted text -

<tibor_please.no.email_kara...@xxxxxxxxxxxxxxxxxx> 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/....


"Ekrem Önsoy" <ek...@xxxxxxxxxxxx> wrote in message


news:1890C2B6-7DD2-40AE-AF10-01981F3ABD51@xxxxxxxxxxxxxxxx


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...@xxxxxxxxx> wrote in message
news:1192722595.538697.92480@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx


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 -





On Oct 18, 3:56 pm, Steve215 <stephen.mer...@xxxxxxxxxxx> wrote:
On Oct 18, 11:50 am, traceable1 <thham...@xxxxxxxxx> wrote:

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

thanks!

This link describes the use of 'Automatic Execution Stored Procedures'
than may fit the bill for what you are looking for.

http://msdn2.microsoft.com/en-us/library/ms191129.aspx


.



Relevant Pages

  • Re: OT: Umra posting statistics for May 2008
    ... rather than adding tabs (which can go all over the place if ... horror when I clicked on the "show formatting" button. ... language Jo's script is written in but something like C or Perl's ... always welcome :-) I'm just using Agent, ...
    (uk.media.radio.archers)
  • Re: Where does the Exchange 2000 Event Service get its session?
    ... I guess I should have mentioned this initially, I'm not using script ... but instead writing a custom agent. ... MAPILogon() I'm remoting the processing of the message which triggered the ... We therefore plan to stick with the Event Service. ...
    (microsoft.public.exchange.development)
  • Re: KDE ssh-agent
    ... I just meant that if you tweak the script and then it gets updated via ... My script checks for a preexisting agent, and if it finds one, it ... before the xinitrc-common script runs, you should be able to easily work ...
    (Fedora)
  • Best practice when using data from external files
    ... I'm looking for some advice on the best practice when using external files to contain data. ... I work in a contact centre and have created a web based stats viewer for my team. ... The script would be smaller if the data file was singular but as the data expands this could take quite a while to read. ... If I have individual data files for each Agent then this would speed up usage, but then the script would become more complex. ...
    (perl.beginners)
  • small script --> huge load --> error message
    ... I'm sure everybody who works with javascript has seen this ... A script on this page is causing mozilla to run slowly. ... way to tell a javascript to give control back to the agent interface ... var oTable, oTHead, oTBody, oTFoot, oCaption; ...
    (comp.lang.javascript)