Showing posts with label plan. Show all posts
Showing posts with label plan. Show all posts

Monday, March 19, 2012

calling all gurus! - simple synchronisation and backups - best plan needed!

Hi,
I'm from a unix background but have worked with SQL server for months in the
past.
I've recently have been asked to implement simple backup and synchronisation
routines for a database.
Basically, there are two servers both running SQL Server 2000.
Every night the data on server 1 needs to be backed up to a file which is
then archived for backup purposes.
An exact copy of the database also needs to be copied onto server 2 which
will overwrite the copy already on there.
This means that server 2 is ready to be used as a hot-swap backup if needed.
Please note - the built-in synchronisation of SQL server is not wanted. The
synchronisation has to happen once during the night and not again until the
following night.
This is because the client runs a few large DTS packages during the day and
can not easily see if the various transactions have completed or not. The
database is between 10/20GB in size and contains masses of numbers relating
to telecoms data.
The transactions are carried out by a ton of spaghetti code written into thr
DTS packages - these involve writing to files and screen after screen of
convoluted transactions.
In the event of a problem all the client wants to be able to do is to revert
to how the data was at 9.00am and rerun his DTS packages. The situation
can be reverted by restoring the backup or by switching to the second
server in the event o something serious happening to the first server.
So - to emphasise the point - I know DTS packages can be made as single
transactions and logs can show if transactions have completed etc but the
client simply wants the data synchronised once during the night and that's
it.
Now I have run the process manually - i.e. backed up the database to a file,
copied the file to the server 2, then restored this file over the old
database on server 2. The file can obviously be copied to an archive
location.
What I am basically asking is where is the best place to script this?
Could I write a batch file on server 2 which could run OSQL commands on
server 1 to backup the DB, copy the file, copy to an archive, then use OSQL
to restore into server 2.
Or should I use scheduled jobs built-in to SQL server. Can these reference
and carry out commands on the other DB? Also, can I run dos commands to
copy files, make dirs etc?
What about permissions?
Most importantly, how do I get feedback from each step of the sequence? Can
results be written to an event log? I know that sending them out via email
is problematic but could this be done?
The daily result email should contain lines like:
08/10/2006 01:01:01 Dumping database...
08/10/2006 02:02:02 Copying file...
08/10/2006 03:03:03 Restoring database on to server 2...
08/10/2006 04:04:04 Finished.
Obviously any error messages from failed steps would appear in the email.
Any pointers towards a neat way of scripting these actions would be
appreciated.
Kevin
How about a SQL Server agent job. This can have many jobsteps and each jobstep can redirect output
to an output file (option to append/overwrite). so you can overwrite for first jobstep and append
the rest. Final jobstep can be to send the email (xp_smtp_sendmail). Assuming job owner has sysadmin
privileges, the OS type jobsteps will execute as Agent service account. So, you can fir instance use
OSQL.EXE from such a job step to login to the "other" SQL Server instance.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kevin bailey" <kbailey@.freewayprojects.com> wrote in message
news:egdfe7$h5l$1$8300dec7@.news.demon.co.uk...
> Hi,
> I'm from a unix background but have worked with SQL server for months in the
> past.
> I've recently have been asked to implement simple backup and synchronisation
> routines for a database.
> Basically, there are two servers both running SQL Server 2000.
> Every night the data on server 1 needs to be backed up to a file which is
> then archived for backup purposes.
> An exact copy of the database also needs to be copied onto server 2 which
> will overwrite the copy already on there.
> This means that server 2 is ready to be used as a hot-swap backup if needed.
> Please note - the built-in synchronisation of SQL server is not wanted. The
> synchronisation has to happen once during the night and not again until the
> following night.
> This is because the client runs a few large DTS packages during the day and
> can not easily see if the various transactions have completed or not. The
> database is between 10/20GB in size and contains masses of numbers relating
> to telecoms data.
> The transactions are carried out by a ton of spaghetti code written into thr
> DTS packages - these involve writing to files and screen after screen of
> convoluted transactions.
> In the event of a problem all the client wants to be able to do is to revert
> to how the data was at 9.00am and rerun his DTS packages. The situation
> can be reverted by restoring the backup or by switching to the second
> server in the event o something serious happening to the first server.
> So - to emphasise the point - I know DTS packages can be made as single
> transactions and logs can show if transactions have completed etc but the
> client simply wants the data synchronised once during the night and that's
> it.
> Now I have run the process manually - i.e. backed up the database to a file,
> copied the file to the server 2, then restored this file over the old
> database on server 2. The file can obviously be copied to an archive
> location.
>
> What I am basically asking is where is the best place to script this?
> Could I write a batch file on server 2 which could run OSQL commands on
> server 1 to backup the DB, copy the file, copy to an archive, then use OSQL
> to restore into server 2.
> Or should I use scheduled jobs built-in to SQL server. Can these reference
> and carry out commands on the other DB? Also, can I run dos commands to
> copy files, make dirs etc?
> What about permissions?
> Most importantly, how do I get feedback from each step of the sequence? Can
> results be written to an event log? I know that sending them out via email
> is problematic but could this be done?
> The daily result email should contain lines like:
> 08/10/2006 01:01:01 Dumping database...
> 08/10/2006 02:02:02 Copying file...
> 08/10/2006 03:03:03 Restoring database on to server 2...
> 08/10/2006 04:04:04 Finished.
>
> Obviously any error messages from failed steps would appear in the email.
> Any pointers towards a neat way of scripting these actions would be
> appreciated.
> Kevin
>
|||Tibor Karaszi wrote:

> How about a SQL Server agent job. This can have many jobsteps and each
> jobstep can redirect output to an output file (option to
> append/overwrite). so you can overwrite for first jobstep and append the
> rest.
Sounds good.

> Final jobstep can be to send the email (xp_smtp_sendmail).
Sounds even better - didn't know that this Sp existed!

> Assuming
> job owner has sysadmin privileges, the OS type jobsteps will execute as
> Agent service account. So, you can fir instance use OSQL.EXE from such a
> job step to login to the "other" SQL Server instance.
>
Thanks for that.
|||Tibor Karaszi wrote:

> How about a SQL Server agent job. This can have many jobsteps and each
> jobstep can redirect output to an output file (option to
> append/overwrite). so you can overwrite for first jobstep and append the
> rest. Final jobstep can be to send the email (xp_smtp_sendmail)
Hmmm... can't find that xp
Presume you mean xp_sendmail.
That needs a mail profile to be set up which the server admin can't get to
for now.
For a minute I thought there was an inbuilt smtp engine. If there is a
simple way for SQL server to send emails it would be useful. But currently
to only bodgearound is to use something like an external app and run it
from the command line.

> . Assuming
> job owner has sysadmin privileges, the OS type jobsteps will execute as
> Agent service account. So, you can fir instance use OSQL.EXE from such a
> job step to login to the "other" SQL Server instance.
>
|||You find xp_smtp_sendmail at www.sqldev.net. It is so commonly used nowadays, so I sometimes take if
for granted that people know about it already... ;-)
2005 has built-in SMTP support, btw...
Oh, I forgot. Perhaps obvious, but you can attach the output file created by earlier jobsteps in the
final e-mailing jobstep (see the parameters to xp_smtp_sendmail). This way you have your email
including details of what each jobstep did, and possible error messages.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kevin bailey" <kbailey@.freewayprojects.com> wrote in message
news:egdofr$l9j$1$8302bc10@.news.demon.co.uk...
> Tibor Karaszi wrote:
>
> Hmmm... can't find that xp
> Presume you mean xp_sendmail.
> That needs a mail profile to be set up which the server admin can't get to
> for now.
> For a minute I thought there was an inbuilt smtp engine. If there is a
> simple way for SQL server to send emails it would be useful. But currently
> to only bodgearound is to use something like an external app and run it
> from the command line.
>
>
|||Tibor Karaszi wrote:

> You find xp_smtp_sendmail at www.sqldev.net. It is so commonly used
> nowadays, so I sometimes take if for granted that people know about it
> already... ;-)
Thanks for the link.

> 2005 has built-in SMTP support, btw...
> Oh, I forgot. Perhaps obvious, but you can attach the output file created
> by earlier jobsteps in the final e-mailing jobstep (see the parameters to
> xp_smtp_sendmail). This way you have your email including details of what
> each jobstep did, and possible error messages.
>
Will try this out.
Kevin

calling all gurus! - simple synchronisation and backups - best plan needed!

Hi,
I'm from a unix background but have worked with SQL server for months in the
past.
I've recently have been asked to implement simple backup and synchronisation
routines for a database.
Basically, there are two servers both running SQL Server 2000.
Every night the data on server 1 needs to be backed up to a file which is
then archived for backup purposes.
An exact copy of the database also needs to be copied onto server 2 which
will overwrite the copy already on there.
This means that server 2 is ready to be used as a hot-swap backup if needed.
Please note - the built-in synchronisation of SQL server is not wanted. The
synchronisation has to happen once during the night and not again until the
following night.
This is because the client runs a few large DTS packages during the day and
can not easily see if the various transactions have completed or not. The
database is between 10/20GB in size and contains masses of numbers relating
to telecoms data.
The transactions are carried out by a ton of spaghetti code written into thr
DTS packages - these involve writing to files and screen after screen of
convoluted transactions.
In the event of a problem all the client wants to be able to do is to revert
to how the data was at 9.00am and rerun his DTS packages. The situation
can be reverted by restoring the backup or by switching to the second
server in the event o something serious happening to the first server.
So - to emphasise the point - I know DTS packages can be made as single
transactions and logs can show if transactions have completed etc but the
client simply wants the data synchronised once during the night and that's
it.
Now I have run the process manually - i.e. backed up the database to a file,
copied the file to the server 2, then restored this file over the old
database on server 2. The file can obviously be copied to an archive
location.
What I am basically asking is where is the best place to script this?
Could I write a batch file on server 2 which could run OSQL commands on
server 1 to backup the DB, copy the file, copy to an archive, then use OSQL
to restore into server 2.
Or should I use scheduled jobs built-in to SQL server. Can these reference
and carry out commands on the other DB? Also, can I run dos commands to
copy files, make dirs etc?
What about permissions?
Most importantly, how do I get feedback from each step of the sequence? Can
results be written to an event log? I know that sending them out via email
is problematic but could this be done?
The daily result email should contain lines like:
08/10/2006 01:01:01 Dumping database...
08/10/2006 02:02:02 Copying file...
08/10/2006 03:03:03 Restoring database on to server 2...
08/10/2006 04:04:04 Finished.
Obviously any error messages from failed steps would appear in the email.
Any pointers towards a neat way of scripting these actions would be
appreciated.
KevinHow about a SQL Server agent job. This can have many jobsteps and each jobstep can redirect output
to an output file (option to append/overwrite). so you can overwrite for first jobstep and append
the rest. Final jobstep can be to send the email (xp_smtp_sendmail). Assuming job owner has sysadmin
privileges, the OS type jobsteps will execute as Agent service account. So, you can fir instance use
OSQL.EXE from such a job step to login to the "other" SQL Server instance.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kevin bailey" <kbailey@.freewayprojects.com> wrote in message
news:egdfe7$h5l$1$8300dec7@.news.demon.co.uk...
> Hi,
> I'm from a unix background but have worked with SQL server for months in the
> past.
> I've recently have been asked to implement simple backup and synchronisation
> routines for a database.
> Basically, there are two servers both running SQL Server 2000.
> Every night the data on server 1 needs to be backed up to a file which is
> then archived for backup purposes.
> An exact copy of the database also needs to be copied onto server 2 which
> will overwrite the copy already on there.
> This means that server 2 is ready to be used as a hot-swap backup if needed.
> Please note - the built-in synchronisation of SQL server is not wanted. The
> synchronisation has to happen once during the night and not again until the
> following night.
> This is because the client runs a few large DTS packages during the day and
> can not easily see if the various transactions have completed or not. The
> database is between 10/20GB in size and contains masses of numbers relating
> to telecoms data.
> The transactions are carried out by a ton of spaghetti code written into thr
> DTS packages - these involve writing to files and screen after screen of
> convoluted transactions.
> In the event of a problem all the client wants to be able to do is to revert
> to how the data was at 9.00am and rerun his DTS packages. The situation
> can be reverted by restoring the backup or by switching to the second
> server in the event o something serious happening to the first server.
> So - to emphasise the point - I know DTS packages can be made as single
> transactions and logs can show if transactions have completed etc but the
> client simply wants the data synchronised once during the night and that's
> it.
> Now I have run the process manually - i.e. backed up the database to a file,
> copied the file to the server 2, then restored this file over the old
> database on server 2. The file can obviously be copied to an archive
> location.
>
> What I am basically asking is where is the best place to script this?
> Could I write a batch file on server 2 which could run OSQL commands on
> server 1 to backup the DB, copy the file, copy to an archive, then use OSQL
> to restore into server 2.
> Or should I use scheduled jobs built-in to SQL server. Can these reference
> and carry out commands on the other DB? Also, can I run dos commands to
> copy files, make dirs etc?
> What about permissions?
> Most importantly, how do I get feedback from each step of the sequence? Can
> results be written to an event log? I know that sending them out via email
> is problematic but could this be done?
> The daily result email should contain lines like:
> 08/10/2006 01:01:01 Dumping database...
> 08/10/2006 02:02:02 Copying file...
> 08/10/2006 03:03:03 Restoring database on to server 2...
> 08/10/2006 04:04:04 Finished.
>
> Obviously any error messages from failed steps would appear in the email.
> Any pointers towards a neat way of scripting these actions would be
> appreciated.
> Kevin
>|||Tibor Karaszi wrote:
> How about a SQL Server agent job. This can have many jobsteps and each
> jobstep can redirect output to an output file (option to
> append/overwrite). so you can overwrite for first jobstep and append the
> rest.
Sounds good.
> Final jobstep can be to send the email (xp_smtp_sendmail).
Sounds even better - didn't know that this Sp existed!
> Assuming
> job owner has sysadmin privileges, the OS type jobsteps will execute as
> Agent service account. So, you can fir instance use OSQL.EXE from such a
> job step to login to the "other" SQL Server instance.
>
Thanks for that.|||Tibor Karaszi wrote:
> How about a SQL Server agent job. This can have many jobsteps and each
> jobstep can redirect output to an output file (option to
> append/overwrite). so you can overwrite for first jobstep and append the
> rest. Final jobstep can be to send the email (xp_smtp_sendmail)
Hmmm... can't find that xp
Presume you mean xp_sendmail.
That needs a mail profile to be set up which the server admin can't get to
for now.
For a minute I thought there was an inbuilt smtp engine. If there is a
simple way for SQL server to send emails it would be useful. But currently
to only bodgearound is to use something like an external app and run it
from the command line.
> . Assuming
> job owner has sysadmin privileges, the OS type jobsteps will execute as
> Agent service account. So, you can fir instance use OSQL.EXE from such a
> job step to login to the "other" SQL Server instance.
>|||You find xp_smtp_sendmail at www.sqldev.net. It is so commonly used nowadays, so I sometimes take if
for granted that people know about it already... ;-)
2005 has built-in SMTP support, btw...
Oh, I forgot. Perhaps obvious, but you can attach the output file created by earlier jobsteps in the
final e-mailing jobstep (see the parameters to xp_smtp_sendmail). This way you have your email
including details of what each jobstep did, and possible error messages.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kevin bailey" <kbailey@.freewayprojects.com> wrote in message
news:egdofr$l9j$1$8302bc10@.news.demon.co.uk...
> Tibor Karaszi wrote:
>> How about a SQL Server agent job. This can have many jobsteps and each
>> jobstep can redirect output to an output file (option to
>> append/overwrite). so you can overwrite for first jobstep and append the
>> rest. Final jobstep can be to send the email (xp_smtp_sendmail)
>
> Hmmm... can't find that xp
> Presume you mean xp_sendmail.
> That needs a mail profile to be set up which the server admin can't get to
> for now.
> For a minute I thought there was an inbuilt smtp engine. If there is a
> simple way for SQL server to send emails it would be useful. But currently
> to only bodgearound is to use something like an external app and run it
> from the command line.
>
>> . Assuming
>> job owner has sysadmin privileges, the OS type jobsteps will execute as
>> Agent service account. So, you can fir instance use OSQL.EXE from such a
>> job step to login to the "other" SQL Server instance.
>|||Tibor Karaszi wrote:
> You find xp_smtp_sendmail at www.sqldev.net. It is so commonly used
> nowadays, so I sometimes take if for granted that people know about it
> already... ;-)
Thanks for the link.
> 2005 has built-in SMTP support, btw...
> Oh, I forgot. Perhaps obvious, but you can attach the output file created
> by earlier jobsteps in the final e-mailing jobstep (see the parameters to
> xp_smtp_sendmail). This way you have your email including details of what
> each jobstep did, and possible error messages.
>
Will try this out.
Kevin

calling all gurus! - simple synchronisation and backups - best plan needed!

Hi,
I'm from a unix background but have worked with SQL server for months in the
past.
I've recently have been asked to implement simple backup and synchronisation
routines for a database.
Basically, there are two servers both running SQL Server 2000.
Every night the data on server 1 needs to be backed up to a file which is
then archived for backup purposes.
An exact copy of the database also needs to be copied onto server 2 which
will overwrite the copy already on there.
This means that server 2 is ready to be used as a hot-swap backup if needed.
Please note - the built-in synchronisation of SQL server is not wanted. The
synchronisation has to happen once during the night and not again until the
following night.
This is because the client runs a few large DTS packages during the day and
can not easily see if the various transactions have completed or not. The
database is between 10/20GB in size and contains masses of numbers relating
to telecoms data.
The transactions are carried out by a ton of spaghetti code written into thr
DTS packages - these involve writing to files and screen after screen of
convoluted transactions.
In the event of a problem all the client wants to be able to do is to revert
to how the data was at 9.00am and rerun his DTS packages. The situation
can be reverted by restoring the backup or by switching to the second
server in the event o something serious happening to the first server.
So - to emphasise the point - I know DTS packages can be made as single
transactions and logs can show if transactions have completed etc but the
client simply wants the data synchronised once during the night and that's
it.
Now I have run the process manually - i.e. backed up the database to a file,
copied the file to the server 2, then restored this file over the old
database on server 2. The file can obviously be copied to an archive
location.
What I am basically asking is where is the best place to script this?
Could I write a batch file on server 2 which could run OSQL commands on
server 1 to backup the DB, copy the file, copy to an archive, then use OSQL
to restore into server 2.
Or should I use scheduled jobs built-in to SQL server. Can these reference
and carry out commands on the other DB? Also, can I run dos commands to
copy files, make dirs etc?
What about permissions?
Most importantly, how do I get feedback from each step of the sequence? Can
results be written to an event log? I know that sending them out via email
is problematic but could this be done?
The daily result email should contain lines like:
08/10/2006 01:01:01 Dumping database...
08/10/2006 02:02:02 Copying file...
08/10/2006 03:03:03 Restoring database on to server 2...
08/10/2006 04:04:04 Finished.
Obviously any error messages from failed steps would appear in the email.
Any pointers towards a neat way of scripting these actions would be
appreciated.
KevinHow about a SQL Server agent job. This can have many jobsteps and each jobst
ep can redirect output
to an output file (option to append/overwrite). so you can overwrite for fir
st jobstep and append
the rest. Final jobstep can be to send the email (xp_smtp_sendmail). Assumin
g job owner has sysadmin
privileges, the OS type jobsteps will execute as Agent service account. So,
you can fir instance use
OSQL.EXE from such a job step to login to the "other" SQL Server instance.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kevin bailey" <kbailey@.freewayprojects.com> wrote in message
news:egdfe7$h5l$1$8300dec7@.news.demon.co.uk...
> Hi,
> I'm from a unix background but have worked with SQL server for months in t
he
> past.
> I've recently have been asked to implement simple backup and synchronisati
on
> routines for a database.
> Basically, there are two servers both running SQL Server 2000.
> Every night the data on server 1 needs to be backed up to a file which is
> then archived for backup purposes.
> An exact copy of the database also needs to be copied onto server 2 which
> will overwrite the copy already on there.
> This means that server 2 is ready to be used as a hot-swap backup if neede
d.
> Please note - the built-in synchronisation of SQL server is not wanted. T
he
> synchronisation has to happen once during the night and not again until th
e
> following night.
> This is because the client runs a few large DTS packages during the day an
d
> can not easily see if the various transactions have completed or not. The
> database is between 10/20GB in size and contains masses of numbers relatin
g
> to telecoms data.
> The transactions are carried out by a ton of spaghetti code written into t
hr
> DTS packages - these involve writing to files and screen after screen of
> convoluted transactions.
> In the event of a problem all the client wants to be able to do is to reve
rt
> to how the data was at 9.00am and rerun his DTS packages. The situation
> can be reverted by restoring the backup or by switching to the second
> server in the event o something serious happening to the first server.
> So - to emphasise the point - I know DTS packages can be made as single
> transactions and logs can show if transactions have completed etc but the
> client simply wants the data synchronised once during the night and that's
> it.
> Now I have run the process manually - i.e. backed up the database to a fil
e,
> copied the file to the server 2, then restored this file over the old
> database on server 2. The file can obviously be copied to an archive
> location.
>
> What I am basically asking is where is the best place to script this?
> Could I write a batch file on server 2 which could run OSQL commands on
> server 1 to backup the DB, copy the file, copy to an archive, then use OSQ
L
> to restore into server 2.
> Or should I use scheduled jobs built-in to SQL server. Can these referenc
e
> and carry out commands on the other DB? Also, can I run dos commands to
> copy files, make dirs etc?
> What about permissions?
> Most importantly, how do I get feedback from each step of the sequence? C
an
> results be written to an event log? I know that sending them out via emai
l
> is problematic but could this be done?
> The daily result email should contain lines like:
> 08/10/2006 01:01:01 Dumping database...
> 08/10/2006 02:02:02 Copying file...
> 08/10/2006 03:03:03 Restoring database on to server 2...
> 08/10/2006 04:04:04 Finished.
>
> Obviously any error messages from failed steps would appear in the email.
> Any pointers towards a neat way of scripting these actions would be
> appreciated.
> Kevin
>|||Tibor Karaszi wrote:

> How about a SQL Server agent job. This can have many jobsteps and each
> jobstep can redirect output to an output file (option to
> append/overwrite). so you can overwrite for first jobstep and append the
> rest.
Sounds good.

> Final jobstep can be to send the email (xp_smtp_sendmail).
Sounds even better - didn't know that this Sp existed!

> Assuming
> job owner has sysadmin privileges, the OS type jobsteps will execute as
> Agent service account. So, you can fir instance use OSQL.EXE from such a
> job step to login to the "other" SQL Server instance.
>
Thanks for that.|||Tibor Karaszi wrote:

> How about a SQL Server agent job. This can have many jobsteps and each
> jobstep can redirect output to an output file (option to
> append/overwrite). so you can overwrite for first jobstep and append the
> rest. Final jobstep can be to send the email (xp_smtp_sendmail)
Hmmm... can't find that xp
Presume you mean xp_sendmail.
That needs a mail profile to be set up which the server admin can't get to
for now.
For a minute I thought there was an inbuilt smtp engine. If there is a
simple way for SQL server to send emails it would be useful. But currently
to only bodgearound is to use something like an external app and run it
from the command line.

> . Assuming
> job owner has sysadmin privileges, the OS type jobsteps will execute as
> Agent service account. So, you can fir instance use OSQL.EXE from such a
> job step to login to the "other" SQL Server instance.
>|||You find xp_smtp_sendmail at www.sqldev.net. It is so commonly used nowadays
, so I sometimes take if
for granted that people know about it already... ;-)
2005 has built-in SMTP support, btw...
Oh, I forgot. Perhaps obvious, but you can attach the output file created by
earlier jobsteps in the
final e-mailing jobstep (see the parameters to xp_smtp_sendmail). This way y
ou have your email
including details of what each jobstep did, and possible error messages.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"kevin bailey" <kbailey@.freewayprojects.com> wrote in message
news:egdofr$l9j$1$8302bc10@.news.demon.co.uk...
> Tibor Karaszi wrote:
>
>
> Hmmm... can't find that xp
> Presume you mean xp_sendmail.
> That needs a mail profile to be set up which the server admin can't get to
> for now.
> For a minute I thought there was an inbuilt smtp engine. If there is a
> simple way for SQL server to send emails it would be useful. But currentl
y
> to only bodgearound is to use something like an external app and run it
> from the command line.
>
>
>|||Tibor Karaszi wrote:

> You find xp_smtp_sendmail at www.sqldev.net. It is so commonly used
> nowadays, so I sometimes take if for granted that people know about it
> already... ;-)
Thanks for the link.

> 2005 has built-in SMTP support, btw...
> Oh, I forgot. Perhaps obvious, but you can attach the output file created
> by earlier jobsteps in the final e-mailing jobstep (see the parameters to
> xp_smtp_sendmail). This way you have your email including details of what
> each jobstep did, and possible error messages.
>
Will try this out.
Kevin

Wednesday, March 7, 2012

call database Maintenance plan from Sql Server Agent->Job

Hi There
can i call database Maintenance plan from Sql Server Agent->Job
what i'm trying to do
I've to truncated records on log table,
then shrink all databases
the call maintenance plan to take all database backup
Thanks
GaneshGanesh
http://www.karaszi.com/SQLServer/info_dont_shrink.asp
"Ganesh" <gsganesh@.yahoo.com> wrote in message
news:A9B19A8E-AE37-4B2B-A0C9-B800E6119472@.microsoft.com...
> Hi There
> can i call database Maintenance plan from Sql Server Agent->Job
> what i'm trying to do
> I've to truncated records on log table,
> then shrink all databases
> the call maintenance plan to take all database backup
> --
> Thanks
> Ganesh|||Probably the best advice the OP should follow, but probably not what he
wanted to hear. :)
ML
http://milambda.blogspot.com/|||Check out this. Let me know if this is what you were looking for.
http://www.dbazine.com/sql/sql-articles/cook10

Tuesday, February 14, 2012

calculating query cost

I was trying to calculate the difference between set-based solution vs
row-by-row solution by looking at the execution plan.
For my row-by-row solution, I have the following (i won't show you the set
based since it is irrelvant here)
SELECT Vendor_ID, (SELECT TOP 1 CONVERT(VARCHAR, Note_Enter_Date, 101) + ' '
+ Note FROM tblNotes WHERE Contact_Type = 1 AND Contact_ID = Vendor_ID ORDER
BY Note_ID DESC) AS Note
FROM tblVendors
WHERE Vendor_Status = 6
As soon as I put the logic (SELECT TOP 1 CONVERT(VARCHAR, Note_Enter_Date,
101) + ' ' + Note FROM tblNotes WHERE Contact_Type = 1 AND Contact_ID =
Vendor_ID ORDER BY Note_ID DESC) in user defined function, query costs are
different? Why is that? Does the optimizer ignore user define function
cost when displaying query cost?
SELECT Vendor_ID, Note = dbo.udf_GetLatestNote(1, Vendor_ID)
FROM tblVendors
WHERE Vendor_Status = 6Hi Justin,
Estimated costs of two query rewrites (or two different queries) are not
always comparable and they shouldn't be used this way.
Only estimated costs of different plans for the same query are comparable,
and they should correlate well with execution time. The primary use of
execution cost is to help the query optimizer rank different plan
alternatives for a query, but not to exactly model the execution time.
Therefore there are things that are not captured in the optimizer's cost
model.
Related to your two query rewrites; in the one with the UDF, the UDF is
compiled separately (you should see two execution plans) and the optimizer
cannot optimize across the UDF boundary or in-line the SELECT statement
inside the UDF (this is something that might be possible in a future version
of SQL Server). Therefore, the query without the UDF has better chances for
a more efficient execution.
Regards,
Leo
"Justin" <nospam@.nospam.com> wrote in message
news:%23KJC%23$vjGHA.4212@.TK2MSFTNGP03.phx.gbl...
>I was trying to calculate the difference between set-based solution vs
>row-by-row solution by looking at the execution plan.
> For my row-by-row solution, I have the following (i won't show you the set
> based since it is irrelvant here)
> SELECT Vendor_ID, (SELECT TOP 1 CONVERT(VARCHAR, Note_Enter_Date, 101) + '
> ' + Note FROM tblNotes WHERE Contact_Type = 1 AND Contact_ID = Vendor_ID
> ORDER BY Note_ID DESC) AS Note
> FROM tblVendors
> WHERE Vendor_Status = 6
> As soon as I put the logic (SELECT TOP 1 CONVERT(VARCHAR, Note_Enter_Date,
> 101) + ' ' + Note FROM tblNotes WHERE Contact_Type = 1 AND Contact_ID =
> Vendor_ID ORDER BY Note_ID DESC) in user defined function, query costs are
> different? Why is that? Does the optimizer ignore user define function
> cost when displaying query cost?
> SELECT Vendor_ID, Note = dbo.udf_GetLatestNote(1, Vendor_ID)
> FROM tblVendors
> WHERE Vendor_Status = 6
>