Showing posts with label job. Show all posts
Showing posts with label job. Show all posts

Friday, March 23, 2012

HOW TO setup SQL MAIL

hi, I want to receive a mail when SQL Server Agent JOB fail,so I go to setup the SQL MAIL,but it skip an error "xp_get_mapi_profiles: Either there is no default mail client or the current mail client cannot fulfill the messaging request. Please run Microsoft Outlook and set it as the default mail client." Someboby can tell me how to solve it?

thank you!

Hi,

SQL Mail needs a mapi file.

You can create this file either with Outlook or with Outlook Express.

regards matthias

|||

Thank you ! can you tell me the detailed resolvent.

|||

don't forget, if you're using SQL 2005, you should use "Database Mail" instead of "SQL Mail" which is being deprecated

http://www.microsoft.com/sql/prodinfo/features/top30features.mspx

http://www.sql-server-performance.com/da_email_functionality.asp

sql

How to setup Operator for sending alerts?

Hello,
I've setup an Operator using the management studio and properly configured
it's settings. However, when I test it by running a job that fires an alert
to the Operator, the alert fails and gives me back the following error.
The job succeeded. The Job was invoked by User XXX. The last step to run
was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Failed
to notify 'John Doe' via pager.
Not sure if this helps but I've properly setup Database Mail via the wizard
along with a default profile and have successfully sent e-mails using the
system sproc for sending emails.
Is there a guide for properly setting up and testing Operator alerts?
P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cause
they are practically dead.
Johnny
I'd run profiler to see what is happening. Does it *try* to send email? If it does, does the TSQL it
submit execute correctly from a query window?
I had problems with Agent Mail in June CTP, so I decided to wait with Agent Mail testing to a later
build.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Johnny" <Johnny@.discussions.microsoft.com> wrote in message
news:E671A826-D5C3-45AA-95AA-E7EF913E84AE@.microsoft.com...
> Hello,
> I've setup an Operator using the management studio and properly configured
> it's settings. However, when I test it by running a job that fires an alert
> to the Operator, the alert fails and gives me back the following error.
> The job succeeded. The Job was invoked by User XXX. The last step to run
> was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Failed
> to notify 'John Doe' via pager.
> Not sure if this helps but I've properly setup Database Mail via the wizard
> along with a default profile and have successfully sent e-mails using the
> system sproc for sending emails.
> Is there a guide for properly setting up and testing Operator alerts?
> P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cause
> they are practically dead.
> Johnny
|||Yahtzee!!!!!!! I found the problem, right before I was getting ready to give
up. I put together some instructions on how to get it to work for those
interested.
Note: With SQL Server Agent Alerts, you have the option of using "Database
Mail" (recommended) or the soon to be removed "SQL Mail" as the mail system.
These instructions show you how to use "Database Mail".
1. Enable "Database Mail" by using the "SQL Server 2005 Surface Area
Configuration" tool.
2. Install "Database Mail" objects in the msdb database.
3. Create a "Database Mail" profile and name it "Default Profile" or
whatever you like.
NOTE: The next step is to tell "SQL Server Agent" that you want to use
"Database Mail" as the mail system and specify a default profile to use. You
are suppose to do this by going to the Alert System page in the SQL Server
Agent Properties. However, the "Database Mail" option is not available in the
drop down menu and therefore you are unable to properly configure this, even
after rebooting the server. We will have to bypass the "UI" provided by the
SQL Server Management Studio and go straight to the registry to specify our
settings.
4. Open the registry editor by going to Start > Run > regedit.
5. Browse to the "SQLServerAgent" section. The path is something like
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microso ft SQL
Server\MSSQL.1\SQLServerAgent".
6. Modify the following entries with the corresponding values listed below.
KeyValue
UseDatabaseMail1
DatabaseMailProfileDefault Profile
7. Restart the "SQL Server Agent" service and voila!!
- Johnny
"Tibor Karaszi" wrote:

> I'd run profiler to see what is happening. Does it *try* to send email? If it does, does the TSQL it
> submit execute correctly from a query window?
> I had problems with Agent Mail in June CTP, so I decided to wait with Agent Mail testing to a later
> build.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Johnny" <Johnny@.discussions.microsoft.com> wrote in message
> news:E671A826-D5C3-45AA-95AA-E7EF913E84AE@.microsoft.com...
>

How to setup Operator for sending alerts?

Hello,
I've setup an Operator using the management studio and properly configured
it's settings. However, when I test it by running a job that fires an alert
to the Operator, the alert fails and gives me back the following error.
The job succeeded. The Job was invoked by User XXX. The last step to run
was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Failed
to notify 'John Doe' via pager.
Not sure if this helps but I've properly setup Database Mail via the wizard
along with a default profile and have successfully sent e-mails using the
system sproc for sending emails.
Is there a guide for properly setting up and testing Operator alerts?
P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cause
they are practically dead.
JohnnyI'd run profiler to see what is happening. Does it *try* to send email? If i
t does, does the TSQL it
submit execute correctly from a query window?
I had problems with Agent Mail in June CTP, so I decided to wait with Agent
Mail testing to a later
build.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Johnny" <Johnny@.discussions.microsoft.com> wrote in message
news:E671A826-D5C3-45AA-95AA-E7EF913E84AE@.microsoft.com...
> Hello,
> I've setup an Operator using the management studio and properly configured
> it's settings. However, when I test it by running a job that fires an aler
t
> to the Operator, the alert fails and gives me back the following error.
> The job succeeded. The Job was invoked by User XXX. The last step to run
> was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Faile
d
> to notify 'John Doe' via pager.
> Not sure if this helps but I've properly setup Database Mail via the wizar
d
> along with a default profile and have successfully sent e-mails using the
> system sproc for sending emails.
> Is there a guide for properly setting up and testing Operator alerts?
> P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cau
se
> they are practically dead.
> Johnny|||Yahtzee!!!!!!! I found the problem, right before I was getting ready to give
up. I put together some instructions on how to get it to work for those
interested.
Note: With SQL Server Agent Alerts, you have the option of using "Database
Mail" (recommended) or the soon to be removed "SQL Mail" as the mail system.
These instructions show you how to use "Database Mail".
1. Enable "Database Mail" by using the "SQL Server 2005 Surface Area
Configuration" tool.
2. Install "Database Mail" objects in the msdb database.
3. Create a "Database Mail" profile and name it "Default Profile" or
whatever you like.
NOTE: The next step is to tell "SQL Server Agent" that you want to use
"Database Mail" as the mail system and specify a default profile to use. You
are suppose to do this by going to the Alert System page in the SQL Server
Agent Properties. However, the "Database Mail" option is not available in th
e
drop down menu and therefore you are unable to properly configure this, even
after rebooting the server. We will have to bypass the "UI" provided by the
SQL Server Management Studio and go straight to the registry to specify our
settings.
4. Open the registry editor by going to Start > Run > regedit.
5. Browse to the "SQLServerAgent" section. The path is something like
" HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Mi
crosoft SQL
Server\MSSQL.1\SQLServerAgent".
6. Modify the following entries with the corresponding values listed below.
Key Value
----
UseDatabaseMail 1
DatabaseMailProfile Default Profile
7. Restart the "SQL Server Agent" service and voila!!
- Johnny
"Tibor Karaszi" wrote:

> I'd run profiler to see what is happening. Does it *try* to send email? If
it does, does the TSQL it
> submit execute correctly from a query window?
> I had problems with Agent Mail in June CTP, so I decided to wait with Agen
t Mail testing to a later
> build.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Johnny" <Johnny@.discussions.microsoft.com> wrote in message
> news:E671A826-D5C3-45AA-95AA-E7EF913E84AE@.microsoft.com...
>

How to setup Operator for sending alerts?

Hello,
I've setup an Operator using the management studio and properly configured
it's settings. However, when I test it by running a job that fires an alert
to the Operator, the alert fails and gives me back the following error.
The job succeeded. The Job was invoked by User XXX. The last step to run
was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Failed
to notify 'John Doe' via pager.
Not sure if this helps but I've properly setup Database Mail via the wizard
along with a default profile and have successfully sent e-mails using the
system sproc for sending emails.
Is there a guide for properly setting up and testing Operator alerts?
P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cause
they are practically dead.
JohnnyI'd run profiler to see what is happening. Does it *try* to send email? If it does, does the TSQL it
submit execute correctly from a query window?
I had problems with Agent Mail in June CTP, so I decided to wait with Agent Mail testing to a later
build.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Johnny" <Johnny@.discussions.microsoft.com> wrote in message
news:E671A826-D5C3-45AA-95AA-E7EF913E84AE@.microsoft.com...
> Hello,
> I've setup an Operator using the management studio and properly configured
> it's settings. However, when I test it by running a job that fires an alert
> to the Operator, the alert fails and gives me back the following error.
> The job succeeded. The Job was invoked by User XXX. The last step to run
> was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Failed
> to notify 'John Doe' via pager.
> Not sure if this helps but I've properly setup Database Mail via the wizard
> along with a default profile and have successfully sent e-mails using the
> system sproc for sending emails.
> Is there a guide for properly setting up and testing Operator alerts?
> P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cause
> they are practically dead.
> Johnny|||Yahtzee!!!!!!! I found the problem, right before I was getting ready to give
up. I put together some instructions on how to get it to work for those
interested.
Note: With SQL Server Agent Alerts, you have the option of using "Database
Mail" (recommended) or the soon to be removed "SQL Mail" as the mail system.
These instructions show you how to use "Database Mail".
1. Enable "Database Mail" by using the "SQL Server 2005 Surface Area
Configuration" tool.
2. Install "Database Mail" objects in the msdb database.
3. Create a "Database Mail" profile and name it "Default Profile" or
whatever you like.
NOTE: The next step is to tell "SQL Server Agent" that you want to use
"Database Mail" as the mail system and specify a default profile to use. You
are suppose to do this by going to the Alert System page in the SQL Server
Agent Properties. However, the "Database Mail" option is not available in the
drop down menu and therefore you are unable to properly configure this, even
after rebooting the server. We will have to bypass the "UI" provided by the
SQL Server Management Studio and go straight to the registry to specify our
settings.
4. Open the registry editor by going to Start > Run > regedit.
5. Browse to the "SQLServerAgent" section. The path is something like
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL
Server\MSSQL.1\SQLServerAgent".
6. Modify the following entries with the corresponding values listed below.
Key Value
----
UseDatabaseMail 1
DatabaseMailProfile Default Profile
7. Restart the "SQL Server Agent" service and voila!!
- Johnny
"Tibor Karaszi" wrote:
> I'd run profiler to see what is happening. Does it *try* to send email? If it does, does the TSQL it
> submit execute correctly from a query window?
> I had problems with Agent Mail in June CTP, so I decided to wait with Agent Mail testing to a later
> build.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Johnny" <Johnny@.discussions.microsoft.com> wrote in message
> news:E671A826-D5C3-45AA-95AA-E7EF913E84AE@.microsoft.com...
> > Hello,
> >
> > I've setup an Operator using the management studio and properly configured
> > it's settings. However, when I test it by running a job that fires an alert
> > to the Operator, the alert fails and gives me back the following error.
> >
> > The job succeeded. The Job was invoked by User XXX. The last step to run
> > was step 1 (X). NOTE: Failed to notify 'John Doe' via email. NOTE: Failed
> > to notify 'John Doe' via pager.
> >
> > Not sure if this helps but I've properly setup Database Mail via the wizard
> > along with a default profile and have successfully sent e-mails using the
> > system sproc for sending emails.
> >
> > Is there a guide for properly setting up and testing Operator alerts?
> >
> > P.S - I am using SQL 2005 April CTP. Didnt post on the SQL 2005 forums cause
> > they are practically dead.
> >
> > Johnny
>

Wednesday, March 21, 2012

how to setup access for sql jobs

Hello,
I have some users that I want to be able to view/add sql job under sql
agent. How can I give them access to this without making them sys admins?
Jake
The users will need to own the jobs to view them if you
don't want them to be members of sysadmin role.
The public role has permissions to execute sp_add_job.
-Sue
On Mon, 18 Oct 2004 16:10:43 -0700, "Jake"
<rondican@.hotmail.com> wrote:

>Hello,
> I have some users that I want to be able to view/add sql job under sql
>agent. How can I give them access to this without making them sys admins?
>Jake
>

how to setup access for sql jobs

Hello,
I have some users that I want to be able to view/add sql job under sql
agent. How can I give them access to this without making them sys admins?
JakeThe users will need to own the jobs to view them if you
don't want them to be members of sysadmin role.
The public role has permissions to execute sp_add_job.
-Sue
On Mon, 18 Oct 2004 16:10:43 -0700, "Jake"
<rondican@.hotmail.com> wrote:

>Hello,
> I have some users that I want to be able to view/add sql job under sql
>agent. How can I give them access to this without making them sys admins?
>Jake
>

how to setup access for sql jobs

Hello,
I have some users that I want to be able to view/add sql job under sql
agent. How can I give them access to this without making them sys admins?
JakeThe users will need to own the jobs to view them if you
don't want them to be members of sysadmin role.
The public role has permissions to execute sp_add_job.
-Sue
On Mon, 18 Oct 2004 16:10:43 -0700, "Jake"
<rondican@.hotmail.com> wrote:
>Hello,
> I have some users that I want to be able to view/add sql job under sql
>agent. How can I give them access to this without making them sys admins?
>Jake
>sql

Monday, March 19, 2012

How to set up permissions for a user, who need to work with SQL Server Agent

I am looking for a good idea or best practice for setting up a security plan which allows users to execute a specific job, owned by the SQL Server Agent Service Account.

I tried to use the msdb SQLAgentOperatorRole, but unfortunately I recognized, that every local job could be executed.

I would like to have only one job executed by the user and all others should be visible, but not executable.

What is the best practice for this request? Can Proxies and credentials be helpful and if yes, how do I have to use them?

In other words: what is the best approach for this request (end user should see and start specific jobs in the SQL Server Agent).

Thanks in advance

Norbert

Owner can execute job as well.|||

Thanks for the hint, but I do not want to have this user as an owner. The owner should be another account. This user (developer) should only have the capability to execute jobs we (DBA) provided to him. He should not see ALL jobs nor should he execute ALL jobs. I would like to set permissions in a way that he can start/stop/enable/disable ONE specific job.

Is there an easy way to realize it? Or maybe a more complicated way?

Regards

Norbert

How to set up a regular job which will put the quesry result into file and email

Dear forum people,

I created a query which suppose to run every 2 weeks. I know how to schedule a job, my question is how to get the query result into a text or excel file.
If I need to use DTS package, please give me a step by step explanation how to move the result into text file and how to email this file.

I am appreciate every answer.

Thank you.

Annyou can do this whole thing with SQLMail.|||Thrasymachus,
please explain me how can I use SQLMail. Please do not get angry with me as I am not sql person, I just create some queries and know how to use some other things from SQL Enterprise Management.
Thank you.|||I do not get angry but I do not repeat readily available information. So, if you go to Start-->Programs-->Microsoft SQL Server-->SQL Server books Online-->Contents-->Admnistering SQL Server-->Managing Servers-->SQL Mail you can read all about this.

If you want to see examples type xp_sendmail in http://www.google.com/codesearch/advanced_code_search.

How to set up a login that should execute a specific SQL Server Agent job

I am looking for a good idea or best practice for setting up a security plan which allows users to execute a specific job, owned by the SQL Server Agent Service Account.

I tried to use the msdb SQLAgentOperatorRole, but unfortunately I recognized, that every local job could be executed.

I would like to have only one job executed by the user and all others should be visible, but not executable.

What is the best practice for this request? Can Proxies and credentials be helpful and if yes, how do I have to use them?

In other words: what is the best approach for this request (end user should see and start specific jobs in the SQL Server Agent).

Thanks in advance

Norbert

Has no one an idea?

Regards

Norbert

|||

I hope, that someone xould give me some hints if it is possible to realize the scenario or not.

Regards

Norbert

How to set up a login that should execute a specific SQL Server Agent job

I am looking for a good idea or best practice for setting up a security plan which allows users to execute a specific job, owned by the SQL Server Agent Service Account.

I tried to use the msdb SQLAgentOperatorRole, but unfortunately I recognized, that every local job could be executed.

I would like to have only one job executed by the user and all others should be visible, but not executable.

What is the best practice for this request? Can Proxies and credentials be helpful and if yes, how do I have to use them?

In other words: what is the best approach for this request (end user should see and start specific jobs in the SQL Server Agent).

Thanks in advance

Norbert

Has no one an idea?

Regards

Norbert

|||

I hope, that someone xould give me some hints if it is possible to realize the scenario or not.

Regards

Norbert

Monday, March 12, 2012

How to set SQL Job continuously run

Hello,
I want to set up one SQL job to continuously run with
minimum break. In another word, the second run of the SQL
Job will start as soon as the first run is completed. Is
there any way to do it?
Thanks a lot,
LixinChange the job step properties, so that when the step completes, it runs it
self again, instead of completing successfully.
--
Denny Cherry
DBA
GameSpy Industries
"Lixin Fan" <lixinf@.mailcode.com> wrote in message
news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> Hello,
> I want to set up one SQL job to continuously run with
> minimum break. In another word, the second run of the SQL
> Job will start as soon as the first run is completed. Is
> there any way to do it?
> Thanks a lot,
> Lixin|||Denny,
Thank you very much.
Since the Job becomes an endless process, do you think
this will cause some potential issues?
Lixin
>--Original Message--
>Change the job step properties, so that when the step
completes, it runs it
>self again, instead of completing successfully.
>--
>Denny Cherry
>DBA
>GameSpy Industries
>"Lixin Fan" <lixinf@.mailcode.com> wrote in message
>news:299801c386ce$22c337f0$a001280a@.phx.gbl...
>> Hello,
>> I want to set up one SQL job to continuously run with
>> minimum break. In another word, the second run of the
SQL
>> Job will start as soon as the first run is completed. Is
>> there any way to do it?
>> Thanks a lot,
>> Lixin
>
>.
>|||It "shouldn't". I've run a job in an endless loop before. I would be an
escape clause in there every day, or every hour so that it exits, and writes
the job history to disk. You can use sp_stop_job to stop the job in it's
tracks. Something like
if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
exec sp_Stop_Job 'JobName'
If you wanted to escape every hour then remove the "datepart(hh, getdate())
= 0 and " from the if statement. Besure to schedule the job to start every
minute of every day, so that when it stops it will automatically restart.
--
Denny Cherry
DBA
GameSpy Industries
"Lixin Fan" <lixinf@.mailcode.com> wrote in message
news:18e9901c386db$09351760$a601280a@.phx.gbl...
> Denny,
> Thank you very much.
> Since the Job becomes an endless process, do you think
> this will cause some potential issues?
> Lixin
> >--Original Message--
> >Change the job step properties, so that when the step
> completes, it runs it
> >self again, instead of completing successfully.
> >
> >--
> >Denny Cherry
> >DBA
> >GameSpy Industries
> >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> >> Hello,
> >>
> >> I want to set up one SQL job to continuously run with
> >> minimum break. In another word, the second run of the
> SQL
> >> Job will start as soon as the first run is completed. Is
> >> there any way to do it?
> >>
> >> Thanks a lot,
> >> Lixin
> >
> >
> >.
> >|||> if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> exec sp_Stop_Job 'JobName'
This may not guarantee that sp_stop_job will always run because the
currently running job may not stop before 00:00. It's safer to do a time
range check.
Another mehtod to run a job repeatly, especially if you don't need the loop
to be very tight, is to schedule the job to start every minute (or any other
time unit). In the job, using an apllication lock to detect whether the job
is still running. Exit immediately if it is.
--
Linchi Shea
linchi_shea@.NOSPAMml.com
"Denny" <mrdenny@.gamespy.com> wrote in message
news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> It "shouldn't". I've run a job in an endless loop before. I would be an
> escape clause in there every day, or every hour so that it exits, and
writes
> the job history to disk. You can use sp_stop_job to stop the job in it's
> tracks. Something like
> if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> exec sp_Stop_Job 'JobName'
> If you wanted to escape every hour then remove the "datepart(hh,
getdate())
> = 0 and " from the if statement. Besure to schedule the job to start
every
> minute of every day, so that when it stops it will automatically restart.
> --
> Denny Cherry
> DBA
> GameSpy Industries
> "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > Denny,
> >
> > Thank you very much.
> >
> > Since the Job becomes an endless process, do you think
> > this will cause some potential issues?
> >
> > Lixin
> >
> > >--Original Message--
> > >Change the job step properties, so that when the step
> > completes, it runs it
> > >self again, instead of completing successfully.
> > >
> > >--
> > >Denny Cherry
> > >DBA
> > >GameSpy Industries
> > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > >> Hello,
> > >>
> > >> I want to set up one SQL job to continuously run with
> > >> minimum break. In another word, the second run of the
> > SQL
> > >> Job will start as soon as the first run is completed. Is
> > >> there any way to do it?
> > >>
> > >> Thanks a lot,
> > >> Lixin
> > >
> > >
> > >.
> > >
>|||> Another mehtod to run a job repeatly, especially if you don't need the loop
> to be very tight, is to schedule the job to start every minute (or any other
> time unit). In the job, using an apllication lock to detect whether the job
> is still running. Exit immediately if it is.
Is that necessary? As far as I understand, Agent will not start a job if it is already running.
Yet another option is to start the job at agent startup and use a loop with in the job (assuming one
TSQL jobstep). The loop is using a simple WAITFOR construct.
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
news:u1ENtQwhDHA.3276@.tk2msftngp13.phx.gbl...
> > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > exec sp_Stop_Job 'JobName'
> This may not guarantee that sp_stop_job will always run because the
> currently running job may not stop before 00:00. It's safer to do a time
> range check.
> Another mehtod to run a job repeatly, especially if you don't need the loop
> to be very tight, is to schedule the job to start every minute (or any other
> time unit). In the job, using an apllication lock to detect whether the job
> is still running. Exit immediately if it is.
> --
> Linchi Shea
> linchi_shea@.NOSPAMml.com
>
> "Denny" <mrdenny@.gamespy.com> wrote in message
> news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> > It "shouldn't". I've run a job in an endless loop before. I would be an
> > escape clause in there every day, or every hour so that it exits, and
> writes
> > the job history to disk. You can use sp_stop_job to stop the job in it's
> > tracks. Something like
> > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > exec sp_Stop_Job 'JobName'
> >
> > If you wanted to escape every hour then remove the "datepart(hh,
> getdate())
> > = 0 and " from the if statement. Besure to schedule the job to start
> every
> > minute of every day, so that when it stops it will automatically restart.
> >
> > --
> > Denny Cherry
> > DBA
> > GameSpy Industries
> > "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > > Denny,
> > >
> > > Thank you very much.
> > >
> > > Since the Job becomes an endless process, do you think
> > > this will cause some potential issues?
> > >
> > > Lixin
> > >
> > > >--Original Message--
> > > >Change the job step properties, so that when the step
> > > completes, it runs it
> > > >self again, instead of completing successfully.
> > > >
> > > >--
> > > >Denny Cherry
> > > >DBA
> > > >GameSpy Industries
> > > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > > >> Hello,
> > > >>
> > > >> I want to set up one SQL job to continuously run with
> > > >> minimum break. In another word, the second run of the
> > > SQL
> > > >> Job will start as soon as the first run is completed. Is
> > > >> there any way to do it?
> > > >>
> > > >> Thanks a lot,
> > > >> Lixin
> > > >
> > > >
> > > >.
> > > >
> >
> >
>|||You're right, Tibor, it's not necessary if you use SQL Server Agent to
schedule the job, which what we are talking about here. Just a habit of
wanting to take the concurrency matter into my own hands -:)
Linchi Shea
linchi_shea@.NOSPAMml.com
"Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
wrote in message news:ubSCczxhDHA.2496@.tk2msftngp13.phx.gbl...
> > Another mehtod to run a job repeatly, especially if you don't need the
loop
> > to be very tight, is to schedule the job to start every minute (or any
other
> > time unit). In the job, using an apllication lock to detect whether the
job
> > is still running. Exit immediately if it is.
> Is that necessary? As far as I understand, Agent will not start a job if
it is already running.
> Yet another option is to start the job at agent startup and use a loop
with in the job (assuming one
> TSQL jobstep). The loop is using a simple WAITFOR construct.
> --
> Tibor Karaszi, SQL Server MVP
> Archive at: http://groups.google.com/groups?oi=djq&as
ugroup=microsoft.public.sqlserver
>
> "Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
> news:u1ENtQwhDHA.3276@.tk2msftngp13.phx.gbl...
> > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > exec sp_Stop_Job 'JobName'
> >
> > This may not guarantee that sp_stop_job will always run because the
> > currently running job may not stop before 00:00. It's safer to do a time
> > range check.
> >
> > Another mehtod to run a job repeatly, especially if you don't need the
loop
> > to be very tight, is to schedule the job to start every minute (or any
other
> > time unit). In the job, using an apllication lock to detect whether the
job
> > is still running. Exit immediately if it is.
> >
> > --
> > Linchi Shea
> > linchi_shea@.NOSPAMml.com
> >
> >
> > "Denny" <mrdenny@.gamespy.com> wrote in message
> > news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> > > It "shouldn't". I've run a job in an endless loop before. I would be
an
> > > escape clause in there every day, or every hour so that it exits, and
> > writes
> > > the job history to disk. You can use sp_stop_job to stop the job in
it's
> > > tracks. Something like
> > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > exec sp_Stop_Job 'JobName'
> > >
> > > If you wanted to escape every hour then remove the "datepart(hh,
> > getdate())
> > > = 0 and " from the if statement. Besure to schedule the job to start
> > every
> > > minute of every day, so that when it stops it will automatically
restart.
> > >
> > > --
> > > Denny Cherry
> > > DBA
> > > GameSpy Industries
> > > "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > > > Denny,
> > > >
> > > > Thank you very much.
> > > >
> > > > Since the Job becomes an endless process, do you think
> > > > this will cause some potential issues?
> > > >
> > > > Lixin
> > > >
> > > > >--Original Message--
> > > > >Change the job step properties, so that when the step
> > > > completes, it runs it
> > > > >self again, instead of completing successfully.
> > > > >
> > > > >--
> > > > >Denny Cherry
> > > > >DBA
> > > > >GameSpy Industries
> > > > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > > > >> Hello,
> > > > >>
> > > > >> I want to set up one SQL job to continuously run with
> > > > >> minimum break. In another word, the second run of the
> > > > SQL
> > > > >> Job will start as soon as the first run is completed. Is
> > > > >> there any way to do it?
> > > > >>
> > > > >> Thanks a lot,
> > > > >> Lixin
> > > > >
> > > > >
> > > > >.
> > > > >
> > >
> > >
> >
> >
>|||> Just a habit of
> wanting to take the concurrency matter into my own hands -:)
And a good habit it is. I wonder whether I should say that I found out the behavior by... chance...?
:-)
--
Tibor Karaszi, SQL Server MVP
Archive at: http://groups.google.com/groups?oi=djq&as ugroup=microsoft.public.sqlserver
"Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
news:el$YUr0hDHA.3204@.TK2MSFTNGP11.phx.gbl...
> You're right, Tibor, it's not necessary if you use SQL Server Agent to
> schedule the job, which what we are talking about here. Just a habit of
> wanting to take the concurrency matter into my own hands -:)
> Linchi Shea
> linchi_shea@.NOSPAMml.com
>
> "Tibor Karaszi" <tibor.please_reply_to_public_forum.karaszi@.cornerstone.se>
> wrote in message news:ubSCczxhDHA.2496@.tk2msftngp13.phx.gbl...
> > > Another mehtod to run a job repeatly, especially if you don't need the
> loop
> > > to be very tight, is to schedule the job to start every minute (or any
> other
> > > time unit). In the job, using an apllication lock to detect whether the
> job
> > > is still running. Exit immediately if it is.
> >
> > Is that necessary? As far as I understand, Agent will not start a job if
> it is already running.
> > Yet another option is to start the job at agent startup and use a loop
> with in the job (assuming one
> > TSQL jobstep). The loop is using a simple WAITFOR construct.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > Archive at: http://groups.google.com/groups?oi=djq&as
> ugroup=microsoft.public.sqlserver
> >
> >
> > "Linchi Shea" <linchi_shea@.NOSPAMml.com> wrote in message
> > news:u1ENtQwhDHA.3276@.tk2msftngp13.phx.gbl...
> > > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > > exec sp_Stop_Job 'JobName'
> > >
> > > This may not guarantee that sp_stop_job will always run because the
> > > currently running job may not stop before 00:00. It's safer to do a time
> > > range check.
> > >
> > > Another mehtod to run a job repeatly, especially if you don't need the
> loop
> > > to be very tight, is to schedule the job to start every minute (or any
> other
> > > time unit). In the job, using an apllication lock to detect whether the
> job
> > > is still running. Exit immediately if it is.
> > >
> > > --
> > > Linchi Shea
> > > linchi_shea@.NOSPAMml.com
> > >
> > >
> > > "Denny" <mrdenny@.gamespy.com> wrote in message
> > > news:eKtYe4uhDHA.2448@.TK2MSFTNGP12.phx.gbl...
> > > > It "shouldn't". I've run a job in an endless loop before. I would be
> an
> > > > escape clause in there every day, or every hour so that it exits, and
> > > writes
> > > > the job history to disk. You can use sp_stop_job to stop the job in
> it's
> > > > tracks. Something like
> > > > if datepart(hh, getdate()) = 0 and datepart(mi, getdate()) = 0
> > > > exec sp_Stop_Job 'JobName'
> > > >
> > > > If you wanted to escape every hour then remove the "datepart(hh,
> > > getdate())
> > > > = 0 and " from the if statement. Besure to schedule the job to start
> > > every
> > > > minute of every day, so that when it stops it will automatically
> restart.
> > > >
> > > > --
> > > > Denny Cherry
> > > > DBA
> > > > GameSpy Industries
> > > > "Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > > news:18e9901c386db$09351760$a601280a@.phx.gbl...
> > > > > Denny,
> > > > >
> > > > > Thank you very much.
> > > > >
> > > > > Since the Job becomes an endless process, do you think
> > > > > this will cause some potential issues?
> > > > >
> > > > > Lixin
> > > > >
> > > > > >--Original Message--
> > > > > >Change the job step properties, so that when the step
> > > > > completes, it runs it
> > > > > >self again, instead of completing successfully.
> > > > > >
> > > > > >--
> > > > > >Denny Cherry
> > > > > >DBA
> > > > > >GameSpy Industries
> > > > > >"Lixin Fan" <lixinf@.mailcode.com> wrote in message
> > > > > >news:299801c386ce$22c337f0$a001280a@.phx.gbl...
> > > > > >> Hello,
> > > > > >>
> > > > > >> I want to set up one SQL job to continuously run with
> > > > > >> minimum break. In another word, the second run of the
> > > > > SQL
> > > > > >> Job will start as soon as the first run is completed. Is
> > > > > >> there any way to do it?
> > > > > >>
> > > > > >> Thanks a lot,
> > > > > >> Lixin
> > > > > >
> > > > > >
> > > > > >.
> > > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>|||>--Original Message--
>It "shouldn't". I've run a job in an endless loop
before. I would be an
>escape clause in there every day, or every hour so that
it exits, and writes
>the job history to disk.
Can you explain why the Job must exit to write history
into disk?
The Job I use has 16 steps. I set up the last step goes
back to the first step when the last step succeeds. I can
view the Job history for each step in EM and
msdb..syshistory table while the Job is endlessly running.
Do you mean that the job history is still only in the
memory instead of disk until I stop the Job?
Thanks,
Lixin|||Yes, you can view each step as that step completes. I've just notices that
if you keep a job running non-stop for a few days, the server can start to
get annoyed with you. Stopping the job every once and a while seams to keep
it from getting to upset.
--
Denny Cherry
DBA
GameSpy Industries
"Lixin Fan" <lixinf@.mailcode.com> wrote in message
news:00a101c3875f$829d5de0$a101280a@.phx.gbl...
> >--Original Message--
> >It "shouldn't". I've run a job in an endless loop
> before. I would be an
> >escape clause in there every day, or every hour so that
> it exits, and writes
> >the job history to disk.
> Can you explain why the Job must exit to write history
> into disk?
> The Job I use has 16 steps. I set up the last step goes
> back to the first step when the last step succeeds. I can
> view the Job history for each step in EM and
> msdb..syshistory table while the Job is endlessly running.
> Do you mean that the job history is still only in the
> memory instead of disk until I stop the Job?
> Thanks,
> Lixin
>
>

Sunday, February 19, 2012

How to send notification to multiple email accounts?

I am in process of setting up job failure notification and one of the requirements that I have is to send notification to multiple users. I would appreciate any suggestion. One of the possible ways would be to create some sort of group account on exchange server with all users added as members. Is there anyway though where I could use users' individual accounts and based on that forward notification to them?

Thanks

Which version of sql server is this?

In SQL Server 2005 you can use Database Mail - http://www.sqlserverclub.com/articles/article05.aspx

In SQL Server 2000 try SQL Mail - http://support.microsoft.com/kb/263556

and also you can send mail using SP_OACreate SP

Refer : http://www.sqlteam.com/article/sending-smtp-mail-using-a-stored-procedure

Madhu

|||

Madhu,

I am sorry for not mentioning in advance that I am using Database Mail in SQL Server 2005 and that is why I am wondering how I could send notification to multiple users from job failure. As I understand using Profile would send email to only one of the accounts listed in that profile. I am quite familiar with Database Mail and I have been using it successfully for almost a year now.

|||

Without creating distribution list or group recipient from Exchange Server, I couldn't find any other way to send job failure notification to multiple people. My solution was to create a procedure that collects history of failed job and add it as a last step to my jobs so that whenever job failed it would execute that last step. Within that procedure I used sp_send_dbmail with a list of users email addresses. Solution seem to work brilliant.