We have a production transactional database which is heavily used about 22-2
3 hours a day. Our Integrity job, when run, takes about 2.5 hours to run an
d disrupts production. This can't be a unique situation, so I'm wondering h
ow other folks approach thi
s scheduling conflict. Would it make sense to run a series of CHECKTABLE an
d NEWALLOC commands on several days instead of the single CHECKDB, which is
run by the Integrity job?
Although we're trying to get production to change their schedule, that won't
be an easy task. Ideally we wanted to run the Integrity job every night, b
ut that doesn't seem feasible. How often should the DBCC be run on the enti
re database / individual ta
bles?
Thanks for your help.There is no standard frequency in which to run integrity checks.
Theoretically you never have to run them as they server no function for the
db itself. What they do is to allow you to be informed of any corruption
that may occur as soon as possible. How soon depends on how often you run
it after a problem occurs. So ideally once a night would be great but some
people can only afford to run them once a week, month or longer. One thing
you can do is to restore the DB to another machine and run the DBCC's there.
If it was corrupt on the original server it will be on the one restored as
well. This way you can run it without disturbing the normal operation and it
can be done on a much less powerful machine since you don't care how long it
takes.
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> We have a production transactional database which is heavily used about
22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
run and disrupts production. This can't be a unique situation, so I'm
wondering how other folks approach this scheduling conflict. Would it make
sense to run a series of CHECKTABLE and NEWALLOC commands on several days
instead of the single CHECKDB, which is run by the Integrity job?
> Although we're trying to get production to change their schedule, that
won't be an easy task. Ideally we wanted to run the Integrity job every
night, but that doesn't seem feasible. How often should the DBCC be run on
the entire database / individual tables?
>
> Thanks for your help.|||Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
2000). This will do an allocation check and physical check of every
allocated page in the database without doing the more time consuming logical
checks. It'll be a magnitude faster at least and will still catch most
hardware-caused errors.
Regards
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> There is no standard frequency in which to run integrity checks.
> Theoretically you never have to run them as they server no function for
the
> db itself. What they do is to allow you to be informed of any corruption
> that may occur as soon as possible. How soon depends on how often you run
> it after a problem occurs. So ideally once a night would be great but
some
> people can only afford to run them once a week, month or longer. One
thing
> you can do is to restore the DB to another machine and run the DBCC's
there.
> If it was corrupt on the original server it will be on the one restored as
> well. This way you can run it without disturbing the normal operation and
it
> can be done on a much less powerful machine since you don't care how long
it
> takes.
> --
> Andrew J. Kelly SQL MVP
>
> "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
> run and disrupts production. This can't be a unique situation, so I'm
> wondering how other folks approach this scheduling conflict. Would it
make
> sense to run a series of CHECKTABLE and NEWALLOC commands on several days
> instead of the single CHECKDB, which is run by the Integrity job?
> won't be an easy task. Ideally we wanted to run the Integrity job every
> night, but that doesn't seem feasible. How often should the DBCC be run
on
> the entire database / individual tables?
>|||have a question for paul. if integrity check job is scheduled thru
maintenance plan. how to specify with physical_only option (i assume default
will be doing the logic check as well).
thank you.
steve
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> 2000). This will do an allocation check and physical check of every
> allocated page in the database without doing the more time consuming
logical
> checks. It'll be a magnitude faster at least and will still catch most
> hardware-caused errors.
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> the
corruption[vbcol=seagreen]
run[vbcol=seagreen]
> some
> thing
> there.
as[vbcol=seagreen]
and[vbcol=seagreen]
> it
long[vbcol=seagreen]
> it
about[vbcol=seagreen]
to[vbcol=seagreen]
> make
days[vbcol=seagreen]
> on
>|||Are there any drawbacks from doing a checktable on a set of tables one night
and then another checktable on the remaining tables another night vs. the c
omplete checkdb all in one night (other than the entire set of tables not ge
tting checked at once)?
If I backup, restore on another machine and run the checkdb on that second m
achine will that be an accurate picture of the state of the production datab
ase? Andrew mentioned that any corruption in the production database would
show up when the database i
s checked on the second server, how do you know that it'll show up on the se
cond system?
Thanks
sean|||You don't have that flexibility. That's one of the drawbacks to using the
maintenance plans. If you want to do anything other than what the wizard
allows you must schedule your own jobs.
Andrew J. Kelly SQL MVP
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:O9%23JDXAJEHA.2604@.tk2msftngp13.phx.gbl...
> have a question for paul. if integrity check job is scheduled thru
> maintenance plan. how to specify with physical_only option (i assume
default
> will be doing the logic check as well).
> thank you.
> steve
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> logical
> rights.
for[vbcol=seagreen]
> corruption
> run
restored[vbcol=seagreen]
> as
> and
> long
> about
> to
> days
that[vbcol=seagreen]
every[vbcol=seagreen]
run[vbcol=seagreen]
>|||The only drawback to doing this separately is that you don't know if you
have a single backup that is fully checked.
As for the corruption in the restore the backup process does not really do
anything to the bits on the page. It just transfers the page bit for bit
and knows little or nothing of what they represent. So essentially any
corruption that DBCC's wall pick up on the original will show up in a
restore as well.
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:03896DD9-4F9B-4BD1-8A09-1D2B6E2607F7@.microsoft.com...
> Are there any drawbacks from doing a checktable on a set of tables one
night and then another checktable on the remaining tables another night vs.
the complete checkdb all in one night (other than the entire set of tables
not getting checked at once)?
> If I backup, restore on another machine and run the checkdb on that second
machine will that be an accurate picture of the state of the production
database? Andrew mentioned that any corruption in the production database
would show up when the database is checked on the second server, how do you
know that it'll show up on the second system?
> Thanks
> sean
Showing posts with label production. Show all posts
Showing posts with label production. Show all posts
Wednesday, March 28, 2012
Scheduling Integrity Job
Labels:
22-23,
database,
heavily,
integrity,
job,
microsoft,
mysql,
oracle,
production,
run,
scheduling,
server,
sql,
transactional
Scheduling Integrity Job
We have a production transactional database which is heavily used about 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to run and disrupts production. This can't be a unique situation, so I'm wondering how other folks approach this scheduling conflict. Would it make sense to run a series of CHECKTABLE and NEWALLOC commands on several days instead of the single CHECKDB, which is run by the Integrity job?
Although we're trying to get production to change their schedule, that won't be an easy task. Ideally we wanted to run the Integrity job every night, but that doesn't seem feasible. How often should the DBCC be run on the entire database / individual tables?
Thanks for your help.There is no standard frequency in which to run integrity checks.
Theoretically you never have to run them as they server no function for the
db itself. What they do is to allow you to be informed of any corruption
that may occur as soon as possible. How soon depends on how often you run
it after a problem occurs. So ideally once a night would be great but some
people can only afford to run them once a week, month or longer. One thing
you can do is to restore the DB to another machine and run the DBCC's there.
If it was corrupt on the original server it will be on the one restored as
well. This way you can run it without disturbing the normal operation and it
can be done on a much less powerful machine since you don't care how long it
takes.
--
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> We have a production transactional database which is heavily used about
22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
run and disrupts production. This can't be a unique situation, so I'm
wondering how other folks approach this scheduling conflict. Would it make
sense to run a series of CHECKTABLE and NEWALLOC commands on several days
instead of the single CHECKDB, which is run by the Integrity job?
> Although we're trying to get production to change their schedule, that
won't be an easy task. Ideally we wanted to run the Integrity job every
night, but that doesn't seem feasible. How often should the DBCC be run on
the entire database / individual tables?
>
> Thanks for your help.|||Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
2000). This will do an allocation check and physical check of every
allocated page in the database without doing the more time consuming logical
checks. It'll be a magnitude faster at least and will still catch most
hardware-caused errors.
Regards
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> There is no standard frequency in which to run integrity checks.
> Theoretically you never have to run them as they server no function for
the
> db itself. What they do is to allow you to be informed of any corruption
> that may occur as soon as possible. How soon depends on how often you run
> it after a problem occurs. So ideally once a night would be great but
some
> people can only afford to run them once a week, month or longer. One
thing
> you can do is to restore the DB to another machine and run the DBCC's
there.
> If it was corrupt on the original server it will be on the one restored as
> well. This way you can run it without disturbing the normal operation and
it
> can be done on a much less powerful machine since you don't care how long
it
> takes.
> --
> Andrew J. Kelly SQL MVP
>
> "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> > We have a production transactional database which is heavily used about
> 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
> run and disrupts production. This can't be a unique situation, so I'm
> wondering how other folks approach this scheduling conflict. Would it
make
> sense to run a series of CHECKTABLE and NEWALLOC commands on several days
> instead of the single CHECKDB, which is run by the Integrity job?
> >
> > Although we're trying to get production to change their schedule, that
> won't be an easy task. Ideally we wanted to run the Integrity job every
> night, but that doesn't seem feasible. How often should the DBCC be run
on
> the entire database / individual tables?
> >
> >
> > Thanks for your help.
>|||have a question for paul. if integrity check job is scheduled thru
maintenance plan. how to specify with physical_only option (i assume default
will be doing the logic check as well).
thank you.
steve
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> 2000). This will do an allocation check and physical check of every
> allocated page in the database without doing the more time consuming
logical
> checks. It'll be a magnitude faster at least and will still catch most
> hardware-caused errors.
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> > There is no standard frequency in which to run integrity checks.
> > Theoretically you never have to run them as they server no function for
> the
> > db itself. What they do is to allow you to be informed of any
corruption
> > that may occur as soon as possible. How soon depends on how often you
run
> > it after a problem occurs. So ideally once a night would be great but
> some
> > people can only afford to run them once a week, month or longer. One
> thing
> > you can do is to restore the DB to another machine and run the DBCC's
> there.
> > If it was corrupt on the original server it will be on the one restored
as
> > well. This way you can run it without disturbing the normal operation
and
> it
> > can be done on a much less powerful machine since you don't care how
long
> it
> > takes.
> >
> > --
> > Andrew J. Kelly SQL MVP
> >
> >
> > "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> > news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> > > We have a production transactional database which is heavily used
about
> > 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours
to
> > run and disrupts production. This can't be a unique situation, so I'm
> > wondering how other folks approach this scheduling conflict. Would it
> make
> > sense to run a series of CHECKTABLE and NEWALLOC commands on several
days
> > instead of the single CHECKDB, which is run by the Integrity job?
> > >
> > > Although we're trying to get production to change their schedule, that
> > won't be an easy task. Ideally we wanted to run the Integrity job every
> > night, but that doesn't seem feasible. How often should the DBCC be run
> on
> > the entire database / individual tables?
> > >
> > >
> > > Thanks for your help.
> >
> >
>|||Are there any drawbacks from doing a checktable on a set of tables one night and then another checktable on the remaining tables another night vs. the complete checkdb all in one night (other than the entire set of tables not getting checked at once)
If I backup, restore on another machine and run the checkdb on that second machine will that be an accurate picture of the state of the production database? Andrew mentioned that any corruption in the production database would show up when the database is checked on the second server, how do you know that it'll show up on the second system
Thank
sean|||You don't have that flexibility. That's one of the drawbacks to using the
maintenance plans. If you want to do anything other than what the wizard
allows you must schedule your own jobs.
--
Andrew J. Kelly SQL MVP
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:O9%23JDXAJEHA.2604@.tk2msftngp13.phx.gbl...
> have a question for paul. if integrity check job is scheduled thru
> maintenance plan. how to specify with physical_only option (i assume
default
> will be doing the logic check as well).
> thank you.
> steve
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> > Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> > 2000). This will do an allocation check and physical check of every
> > allocated page in the database without doing the more time consuming
> logical
> > checks. It'll be a magnitude faster at least and will still catch most
> > hardware-caused errors.
> >
> > Regards
> >
> > --
> > Paul Randal
> > Dev Lead, Microsoft SQL Server Storage Engine
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> > "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> > news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> > > There is no standard frequency in which to run integrity checks.
> > > Theoretically you never have to run them as they server no function
for
> > the
> > > db itself. What they do is to allow you to be informed of any
> corruption
> > > that may occur as soon as possible. How soon depends on how often you
> run
> > > it after a problem occurs. So ideally once a night would be great but
> > some
> > > people can only afford to run them once a week, month or longer. One
> > thing
> > > you can do is to restore the DB to another machine and run the DBCC's
> > there.
> > > If it was corrupt on the original server it will be on the one
restored
> as
> > > well. This way you can run it without disturbing the normal operation
> and
> > it
> > > can be done on a much less powerful machine since you don't care how
> long
> > it
> > > takes.
> > >
> > > --
> > > Andrew J. Kelly SQL MVP
> > >
> > >
> > > "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> > > news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> > > > We have a production transactional database which is heavily used
> about
> > > 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours
> to
> > > run and disrupts production. This can't be a unique situation, so I'm
> > > wondering how other folks approach this scheduling conflict. Would it
> > make
> > > sense to run a series of CHECKTABLE and NEWALLOC commands on several
> days
> > > instead of the single CHECKDB, which is run by the Integrity job?
> > > >
> > > > Although we're trying to get production to change their schedule,
that
> > > won't be an easy task. Ideally we wanted to run the Integrity job
every
> > > night, but that doesn't seem feasible. How often should the DBCC be
run
> > on
> > > the entire database / individual tables?
> > > >
> > > >
> > > > Thanks for your help.
> > >
> > >
> >
> >
>|||The only drawback to doing this separately is that you don't know if you
have a single backup that is fully checked.
As for the corruption in the restore the backup process does not really do
anything to the bits on the page. It just transfers the page bit for bit
and knows little or nothing of what they represent. So essentially any
corruption that DBCC's wall pick up on the original will show up in a
restore as well.
--
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:03896DD9-4F9B-4BD1-8A09-1D2B6E2607F7@.microsoft.com...
> Are there any drawbacks from doing a checktable on a set of tables one
night and then another checktable on the remaining tables another night vs.
the complete checkdb all in one night (other than the entire set of tables
not getting checked at once)?
> If I backup, restore on another machine and run the checkdb on that second
machine will that be an accurate picture of the state of the production
database? Andrew mentioned that any corruption in the production database
would show up when the database is checked on the second server, how do you
know that it'll show up on the second system?
> Thanks
> seansql
Although we're trying to get production to change their schedule, that won't be an easy task. Ideally we wanted to run the Integrity job every night, but that doesn't seem feasible. How often should the DBCC be run on the entire database / individual tables?
Thanks for your help.There is no standard frequency in which to run integrity checks.
Theoretically you never have to run them as they server no function for the
db itself. What they do is to allow you to be informed of any corruption
that may occur as soon as possible. How soon depends on how often you run
it after a problem occurs. So ideally once a night would be great but some
people can only afford to run them once a week, month or longer. One thing
you can do is to restore the DB to another machine and run the DBCC's there.
If it was corrupt on the original server it will be on the one restored as
well. This way you can run it without disturbing the normal operation and it
can be done on a much less powerful machine since you don't care how long it
takes.
--
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> We have a production transactional database which is heavily used about
22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
run and disrupts production. This can't be a unique situation, so I'm
wondering how other folks approach this scheduling conflict. Would it make
sense to run a series of CHECKTABLE and NEWALLOC commands on several days
instead of the single CHECKDB, which is run by the Integrity job?
> Although we're trying to get production to change their schedule, that
won't be an easy task. Ideally we wanted to run the Integrity job every
night, but that doesn't seem feasible. How often should the DBCC be run on
the entire database / individual tables?
>
> Thanks for your help.|||Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
2000). This will do an allocation check and physical check of every
allocated page in the database without doing the more time consuming logical
checks. It'll be a magnitude faster at least and will still catch most
hardware-caused errors.
Regards
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> There is no standard frequency in which to run integrity checks.
> Theoretically you never have to run them as they server no function for
the
> db itself. What they do is to allow you to be informed of any corruption
> that may occur as soon as possible. How soon depends on how often you run
> it after a problem occurs. So ideally once a night would be great but
some
> people can only afford to run them once a week, month or longer. One
thing
> you can do is to restore the DB to another machine and run the DBCC's
there.
> If it was corrupt on the original server it will be on the one restored as
> well. This way you can run it without disturbing the normal operation and
it
> can be done on a much less powerful machine since you don't care how long
it
> takes.
> --
> Andrew J. Kelly SQL MVP
>
> "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> > We have a production transactional database which is heavily used about
> 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
> run and disrupts production. This can't be a unique situation, so I'm
> wondering how other folks approach this scheduling conflict. Would it
make
> sense to run a series of CHECKTABLE and NEWALLOC commands on several days
> instead of the single CHECKDB, which is run by the Integrity job?
> >
> > Although we're trying to get production to change their schedule, that
> won't be an easy task. Ideally we wanted to run the Integrity job every
> night, but that doesn't seem feasible. How often should the DBCC be run
on
> the entire database / individual tables?
> >
> >
> > Thanks for your help.
>|||have a question for paul. if integrity check job is scheduled thru
maintenance plan. how to specify with physical_only option (i assume default
will be doing the logic check as well).
thank you.
steve
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> 2000). This will do an allocation check and physical check of every
> allocated page in the database without doing the more time consuming
logical
> checks. It'll be a magnitude faster at least and will still catch most
> hardware-caused errors.
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
rights.
> "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> > There is no standard frequency in which to run integrity checks.
> > Theoretically you never have to run them as they server no function for
> the
> > db itself. What they do is to allow you to be informed of any
corruption
> > that may occur as soon as possible. How soon depends on how often you
run
> > it after a problem occurs. So ideally once a night would be great but
> some
> > people can only afford to run them once a week, month or longer. One
> thing
> > you can do is to restore the DB to another machine and run the DBCC's
> there.
> > If it was corrupt on the original server it will be on the one restored
as
> > well. This way you can run it without disturbing the normal operation
and
> it
> > can be done on a much less powerful machine since you don't care how
long
> it
> > takes.
> >
> > --
> > Andrew J. Kelly SQL MVP
> >
> >
> > "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> > news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> > > We have a production transactional database which is heavily used
about
> > 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours
to
> > run and disrupts production. This can't be a unique situation, so I'm
> > wondering how other folks approach this scheduling conflict. Would it
> make
> > sense to run a series of CHECKTABLE and NEWALLOC commands on several
days
> > instead of the single CHECKDB, which is run by the Integrity job?
> > >
> > > Although we're trying to get production to change their schedule, that
> > won't be an easy task. Ideally we wanted to run the Integrity job every
> > night, but that doesn't seem feasible. How often should the DBCC be run
> on
> > the entire database / individual tables?
> > >
> > >
> > > Thanks for your help.
> >
> >
>|||Are there any drawbacks from doing a checktable on a set of tables one night and then another checktable on the remaining tables another night vs. the complete checkdb all in one night (other than the entire set of tables not getting checked at once)
If I backup, restore on another machine and run the checkdb on that second machine will that be an accurate picture of the state of the production database? Andrew mentioned that any corruption in the production database would show up when the database is checked on the second server, how do you know that it'll show up on the second system
Thank
sean|||You don't have that flexibility. That's one of the drawbacks to using the
maintenance plans. If you want to do anything other than what the wizard
allows you must schedule your own jobs.
--
Andrew J. Kelly SQL MVP
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:O9%23JDXAJEHA.2604@.tk2msftngp13.phx.gbl...
> have a question for paul. if integrity check job is scheduled thru
> maintenance plan. how to specify with physical_only option (i assume
default
> will be doing the logic check as well).
> thank you.
> steve
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> > Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> > 2000). This will do an allocation check and physical check of every
> > allocated page in the database without doing the more time consuming
> logical
> > checks. It'll be a magnitude faster at least and will still catch most
> > hardware-caused errors.
> >
> > Regards
> >
> > --
> > Paul Randal
> > Dev Lead, Microsoft SQL Server Storage Engine
> >
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> >
> > "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> > news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> > > There is no standard frequency in which to run integrity checks.
> > > Theoretically you never have to run them as they server no function
for
> > the
> > > db itself. What they do is to allow you to be informed of any
> corruption
> > > that may occur as soon as possible. How soon depends on how often you
> run
> > > it after a problem occurs. So ideally once a night would be great but
> > some
> > > people can only afford to run them once a week, month or longer. One
> > thing
> > > you can do is to restore the DB to another machine and run the DBCC's
> > there.
> > > If it was corrupt on the original server it will be on the one
restored
> as
> > > well. This way you can run it without disturbing the normal operation
> and
> > it
> > > can be done on a much less powerful machine since you don't care how
> long
> > it
> > > takes.
> > >
> > > --
> > > Andrew J. Kelly SQL MVP
> > >
> > >
> > > "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> > > news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> > > > We have a production transactional database which is heavily used
> about
> > > 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours
> to
> > > run and disrupts production. This can't be a unique situation, so I'm
> > > wondering how other folks approach this scheduling conflict. Would it
> > make
> > > sense to run a series of CHECKTABLE and NEWALLOC commands on several
> days
> > > instead of the single CHECKDB, which is run by the Integrity job?
> > > >
> > > > Although we're trying to get production to change their schedule,
that
> > > won't be an easy task. Ideally we wanted to run the Integrity job
every
> > > night, but that doesn't seem feasible. How often should the DBCC be
run
> > on
> > > the entire database / individual tables?
> > > >
> > > >
> > > > Thanks for your help.
> > >
> > >
> >
> >
>|||The only drawback to doing this separately is that you don't know if you
have a single backup that is fully checked.
As for the corruption in the restore the backup process does not really do
anything to the bits on the page. It just transfers the page bit for bit
and knows little or nothing of what they represent. So essentially any
corruption that DBCC's wall pick up on the original will show up in a
restore as well.
--
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:03896DD9-4F9B-4BD1-8A09-1D2B6E2607F7@.microsoft.com...
> Are there any drawbacks from doing a checktable on a set of tables one
night and then another checktable on the remaining tables another night vs.
the complete checkdb all in one night (other than the entire set of tables
not getting checked at once)?
> If I backup, restore on another machine and run the checkdb on that second
machine will that be an accurate picture of the state of the production
database? Andrew mentioned that any corruption in the production database
would show up when the database is checked on the second server, how do you
know that it'll show up on the second system?
> Thanks
> seansql
Labels:
22-23,
database,
heavily,
integrity,
job,
microsoft,
mysql,
oracle,
production,
run,
scheduling,
server,
sql,
transactional
Scheduling Integrity Job
We have a production transactional database which is heavily used about 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to run and disrupts production. This can't be a unique situation, so I'm wondering how other folks approach thi
s scheduling conflict. Would it make sense to run a series of CHECKTABLE and NEWALLOC commands on several days instead of the single CHECKDB, which is run by the Integrity job?
Although we're trying to get production to change their schedule, that won't be an easy task. Ideally we wanted to run the Integrity job every night, but that doesn't seem feasible. How often should the DBCC be run on the entire database / individual ta
bles?
Thanks for your help.
There is no standard frequency in which to run integrity checks.
Theoretically you never have to run them as they server no function for the
db itself. What they do is to allow you to be informed of any corruption
that may occur as soon as possible. How soon depends on how often you run
it after a problem occurs. So ideally once a night would be great but some
people can only afford to run them once a week, month or longer. One thing
you can do is to restore the DB to another machine and run the DBCC's there.
If it was corrupt on the original server it will be on the one restored as
well. This way you can run it without disturbing the normal operation and it
can be done on a much less powerful machine since you don't care how long it
takes.
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> We have a production transactional database which is heavily used about
22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
run and disrupts production. This can't be a unique situation, so I'm
wondering how other folks approach this scheduling conflict. Would it make
sense to run a series of CHECKTABLE and NEWALLOC commands on several days
instead of the single CHECKDB, which is run by the Integrity job?
> Although we're trying to get production to change their schedule, that
won't be an easy task. Ideally we wanted to run the Integrity job every
night, but that doesn't seem feasible. How often should the DBCC be run on
the entire database / individual tables?
>
> Thanks for your help.
|||Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
2000). This will do an allocation check and physical check of every
allocated page in the database without doing the more time consuming logical
checks. It'll be a magnitude faster at least and will still catch most
hardware-caused errors.
Regards
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> There is no standard frequency in which to run integrity checks.
> Theoretically you never have to run them as they server no function for
the
> db itself. What they do is to allow you to be informed of any corruption
> that may occur as soon as possible. How soon depends on how often you run
> it after a problem occurs. So ideally once a night would be great but
some
> people can only afford to run them once a week, month or longer. One
thing
> you can do is to restore the DB to another machine and run the DBCC's
there.
> If it was corrupt on the original server it will be on the one restored as
> well. This way you can run it without disturbing the normal operation and
it
> can be done on a much less powerful machine since you don't care how long
it
> takes.
> --
> Andrew J. Kelly SQL MVP
>
> "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
> run and disrupts production. This can't be a unique situation, so I'm
> wondering how other folks approach this scheduling conflict. Would it
make
> sense to run a series of CHECKTABLE and NEWALLOC commands on several days
> instead of the single CHECKDB, which is run by the Integrity job?
> won't be an easy task. Ideally we wanted to run the Integrity job every
> night, but that doesn't seem feasible. How often should the DBCC be run
on
> the entire database / individual tables?
>
|||have a question for paul. if integrity check job is scheduled thru
maintenance plan. how to specify with physical_only option (i assume default
will be doing the logic check as well).
thank you.
steve
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> 2000). This will do an allocation check and physical check of every
> allocated page in the database without doing the more time consuming
logical
> checks. It'll be a magnitude faster at least and will still catch most
> hardware-caused errors.
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
rights.[vbcol=seagreen]
> "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> the
corruption[vbcol=seagreen]
run[vbcol=seagreen]
> some
> thing
> there.
as[vbcol=seagreen]
and[vbcol=seagreen]
> it
long[vbcol=seagreen]
> it
about[vbcol=seagreen]
to[vbcol=seagreen]
> make
days
> on
>
|||Are there any drawbacks from doing a checktable on a set of tables one night and then another checktable on the remaining tables another night vs. the complete checkdb all in one night (other than the entire set of tables not getting checked at once)?
If I backup, restore on another machine and run the checkdb on that second machine will that be an accurate picture of the state of the production database? Andrew mentioned that any corruption in the production database would show up when the database i
s checked on the second server, how do you know that it'll show up on the second system?
Thanks
sean
|||You don't have that flexibility. That's one of the drawbacks to using the
maintenance plans. If you want to do anything other than what the wizard
allows you must schedule your own jobs.
Andrew J. Kelly SQL MVP
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:O9%23JDXAJEHA.2604@.tk2msftngp13.phx.gbl...
> have a question for paul. if integrity check job is scheduled thru
> maintenance plan. how to specify with physical_only option (i assume
default[vbcol=seagreen]
> will be doing the logic check as well).
> thank you.
> steve
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> logical
> rights.
for[vbcol=seagreen]
> corruption
> run
restored[vbcol=seagreen]
> as
> and
> long
> about
> to
> days
that[vbcol=seagreen]
every[vbcol=seagreen]
run
>
|||The only drawback to doing this separately is that you don't know if you
have a single backup that is fully checked.
As for the corruption in the restore the backup process does not really do
anything to the bits on the page. It just transfers the page bit for bit
and knows little or nothing of what they represent. So essentially any
corruption that DBCC's wall pick up on the original will show up in a
restore as well.
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:03896DD9-4F9B-4BD1-8A09-1D2B6E2607F7@.microsoft.com...
> Are there any drawbacks from doing a checktable on a set of tables one
night and then another checktable on the remaining tables another night vs.
the complete checkdb all in one night (other than the entire set of tables
not getting checked at once)?
> If I backup, restore on another machine and run the checkdb on that second
machine will that be an accurate picture of the state of the production
database? Andrew mentioned that any corruption in the production database
would show up when the database is checked on the second server, how do you
know that it'll show up on the second system?
> Thanks
> sean
s scheduling conflict. Would it make sense to run a series of CHECKTABLE and NEWALLOC commands on several days instead of the single CHECKDB, which is run by the Integrity job?
Although we're trying to get production to change their schedule, that won't be an easy task. Ideally we wanted to run the Integrity job every night, but that doesn't seem feasible. How often should the DBCC be run on the entire database / individual ta
bles?
Thanks for your help.
There is no standard frequency in which to run integrity checks.
Theoretically you never have to run them as they server no function for the
db itself. What they do is to allow you to be informed of any corruption
that may occur as soon as possible. How soon depends on how often you run
it after a problem occurs. So ideally once a night would be great but some
people can only afford to run them once a week, month or longer. One thing
you can do is to restore the DB to another machine and run the DBCC's there.
If it was corrupt on the original server it will be on the one restored as
well. This way you can run it without disturbing the normal operation and it
can be done on a much less powerful machine since you don't care how long it
takes.
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> We have a production transactional database which is heavily used about
22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
run and disrupts production. This can't be a unique situation, so I'm
wondering how other folks approach this scheduling conflict. Would it make
sense to run a series of CHECKTABLE and NEWALLOC commands on several days
instead of the single CHECKDB, which is run by the Integrity job?
> Although we're trying to get production to change their schedule, that
won't be an easy task. Ideally we wanted to run the Integrity job every
night, but that doesn't seem feasible. How often should the DBCC be run on
the entire database / individual tables?
>
> Thanks for your help.
|||Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
2000). This will do an allocation check and physical check of every
allocated page in the database without doing the more time consuming logical
checks. It'll be a magnitude faster at least and will still catch most
hardware-caused errors.
Regards
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> There is no standard frequency in which to run integrity checks.
> Theoretically you never have to run them as they server no function for
the
> db itself. What they do is to allow you to be informed of any corruption
> that may occur as soon as possible. How soon depends on how often you run
> it after a problem occurs. So ideally once a night would be great but
some
> people can only afford to run them once a week, month or longer. One
thing
> you can do is to restore the DB to another machine and run the DBCC's
there.
> If it was corrupt on the original server it will be on the one restored as
> well. This way you can run it without disturbing the normal operation and
it
> can be done on a much less powerful machine since you don't care how long
it
> takes.
> --
> Andrew J. Kelly SQL MVP
>
> "slambert007" <anonymous@.discussions.microsoft.com> wrote in message
> news:8CF141A0-9C67-4AFA-AA0E-6EF4864FD295@.microsoft.com...
> 22-23 hours a day. Our Integrity job, when run, takes about 2.5 hours to
> run and disrupts production. This can't be a unique situation, so I'm
> wondering how other folks approach this scheduling conflict. Would it
make
> sense to run a series of CHECKTABLE and NEWALLOC commands on several days
> instead of the single CHECKDB, which is run by the Integrity job?
> won't be an easy task. Ideally we wanted to run the Integrity job every
> night, but that doesn't seem feasible. How often should the DBCC be run
on
> the entire database / individual tables?
>
|||have a question for paul. if integrity check job is scheduled thru
maintenance plan. how to specify with physical_only option (i assume default
will be doing the logic check as well).
thank you.
steve
"Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> Use the WITH PHYSICAL_ONLY option (assuming you're running on SQL Server
> 2000). This will do an allocation check and physical check of every
> allocated page in the database without doing the more time consuming
logical
> checks. It'll be a magnitude faster at least and will still catch most
> hardware-caused errors.
> Regards
> --
> Paul Randal
> Dev Lead, Microsoft SQL Server Storage Engine
> This posting is provided "AS IS" with no warranties, and confers no
rights.[vbcol=seagreen]
> "Andrew J. Kelly" <sqlmvpnoooospam@.shadhawk.com> wrote in message
> news:#FvMQQcIEHA.4052@.TK2MSFTNGP12.phx.gbl...
> the
corruption[vbcol=seagreen]
run[vbcol=seagreen]
> some
> thing
> there.
as[vbcol=seagreen]
and[vbcol=seagreen]
> it
long[vbcol=seagreen]
> it
about[vbcol=seagreen]
to[vbcol=seagreen]
> make
days
> on
>
|||Are there any drawbacks from doing a checktable on a set of tables one night and then another checktable on the remaining tables another night vs. the complete checkdb all in one night (other than the entire set of tables not getting checked at once)?
If I backup, restore on another machine and run the checkdb on that second machine will that be an accurate picture of the state of the production database? Andrew mentioned that any corruption in the production database would show up when the database i
s checked on the second server, how do you know that it'll show up on the second system?
Thanks
sean
|||You don't have that flexibility. That's one of the drawbacks to using the
maintenance plans. If you want to do anything other than what the wizard
allows you must schedule your own jobs.
Andrew J. Kelly SQL MVP
"Steve Lin" <lins@.nospam.portptld.com> wrote in message
news:O9%23JDXAJEHA.2604@.tk2msftngp13.phx.gbl...
> have a question for paul. if integrity check job is scheduled thru
> maintenance plan. how to specify with physical_only option (i assume
default[vbcol=seagreen]
> will be doing the logic check as well).
> thank you.
> steve
> "Paul S Randal [MS]" <prandal@.online.microsoft.com> wrote in message
> news:#ua4lzhIEHA.3060@.TK2MSFTNGP11.phx.gbl...
> logical
> rights.
for[vbcol=seagreen]
> corruption
> run
restored[vbcol=seagreen]
> as
> and
> long
> about
> to
> days
that[vbcol=seagreen]
every[vbcol=seagreen]
run
>
|||The only drawback to doing this separately is that you don't know if you
have a single backup that is fully checked.
As for the corruption in the restore the backup process does not really do
anything to the bits on the page. It just transfers the page bit for bit
and knows little or nothing of what they represent. So essentially any
corruption that DBCC's wall pick up on the original will show up in a
restore as well.
Andrew J. Kelly SQL MVP
"slambert007" <anonymous@.discussions.microsoft.com> wrote in message
news:03896DD9-4F9B-4BD1-8A09-1D2B6E2607F7@.microsoft.com...
> Are there any drawbacks from doing a checktable on a set of tables one
night and then another checktable on the remaining tables another night vs.
the complete checkdb all in one night (other than the entire set of tables
not getting checked at once)?
> If I backup, restore on another machine and run the checkdb on that second
machine will that be an accurate picture of the state of the production
database? Andrew mentioned that any corruption in the production database
would show up when the database is checked on the second server, how do you
know that it'll show up on the second system?
> Thanks
> sean
Labels:
22-23,
database,
heavily,
integrity,
job,
microsoft,
mysql,
oracle,
production,
run,
scheduling,
server,
sql,
transactional
Monday, March 26, 2012
Scheduling DB Scripting
Is there any way I can schedule DB scripting? Let's say I want to script
every production DB on a daily bases.
Thank you in advance for your help
Leon ShargorodskyCreate a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/databas...evaluation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
[vbcol=seagreen]
> or you could use a free scripting tool which has a com interface and creat
e
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/databas...evaluation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
>
every production DB on a daily bases.
Thank you in advance for your help
Leon ShargorodskyCreate a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/databas...evaluation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
[vbcol=seagreen]
> or you could use a free scripting tool which has a com interface and creat
e
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/databas...evaluation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
>
Labels:
advance,
bases,
database,
microsoft,
mysql,
oracle,
production,
schedule,
scheduling,
scriptevery,
scripting,
server,
sql
Scheduling DB Scripting
Is there any way I can schedule DB scripting? Let's say I want to script
every production DB on a daily bases.
Thank you in advance for your help
Leon ShargorodskyCreate a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/database_change_management_evaluation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
> or you could use a free scripting tool which has a com interface and create
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/database_change_management_evaluation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
> > Is there any way I can schedule DB scripting? Let's say I want to script
> > every production DB on a daily bases.
> >
> > Thank you in advance for your help
> >
> > Leon Shargorodsky
every production DB on a daily bases.
Thank you in advance for your help
Leon ShargorodskyCreate a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/database_change_management_evaluation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
> or you could use a free scripting tool which has a com interface and create
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/database_change_management_evaluation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
> > Is there any way I can schedule DB scripting? Let's say I want to script
> > every production DB on a daily bases.
> >
> > Thank you in advance for your help
> >
> > Leon Shargorodsky
Scheduling DB Scripting
Is there any way I can schedule DB scripting? Let's say I want to script
every production DB on a daily bases.
Thank you in advance for your help
Leon Shargorodsky
Create a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky
|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/database...valuation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky
|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
[vbcol=seagreen]
> or you could use a free scripting tool which has a com interface and create
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/database...valuation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
sql
every production DB on a daily bases.
Thank you in advance for your help
Leon Shargorodsky
Create a job with an ActiveX type and use DMO to script the db's. Here is a
sample:
-- **** SCRIPT ALL USER DB's **** --
Sub Main()
Dim oSS
Set oSS = CreateObject("SQLDMO.SQLServer2")
Dim oDb
Set oDb = CreateObject("SQLDMO.Database2")
Dim lcPwd
Dim lcServer
Dim lcFile
Dim lcDB
lcServer = "BULLDOG2"
oSS.LoginSecure = True
oSS.Connect lcServer
Dim lcDBList
Dim dbArray
lcDBList = "Presents|Northwind|Model"
dbArray = Split(lcDBList, "|")
For Each lcDB In dbArray
Set oDb = oSS.Databases(lcDB)
Dim oT
Set oT = CreateObject("SQLDMO.Transfer2")
lcFile = "C:\Data\DB_Scripts\" & lcDB & "_" & Year(Now) & Right("0"
& Month(Now), 2) & Right("0" & Day(Now), 2) & ".sql"
oT.CopyAllObjects = True
oT.IncludeUsers = True
oT.IncludeLogins = True
oT.IncludeDB = True
oDb.ScriptTransfer oT, 2, lcFile
Set oT = Nothing
Next
Set oDb = Nothing
Set oSS = Nothing
End Sub
Andrew J. Kelly SQL MVP
"Leon Shargorodsky" <LeonShargorodsky@.discussions.microsoft.com> wrote in
message news:C0204E43-0613-4D6B-AE28-53F6DCA3B405@.microsoft.com...
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky
|||or you could use a free scripting tool which has a com interface and create
vb script to run it, then create a sql job with an active x step in it and
schedule it to a time you want -
http://www.innovartis.co.uk/database...valuation.aspx
It comes free with an evaluation copy of DB Ghost
"Leon Shargorodsky" wrote:
> Is there any way I can schedule DB scripting? Let's say I want to script
> every production DB on a daily bases.
> Thank you in advance for your help
> Leon Shargorodsky
|||Andrew, Mark, thanks a lot for your help!
"mark baekdal" wrote:
[vbcol=seagreen]
> or you could use a free scripting tool which has a com interface and create
> vb script to run it, then create a sql job with an active x step in it and
> schedule it to a time you want -
> http://www.innovartis.co.uk/database...valuation.aspx
> It comes free with an evaluation copy of DB Ghost
> "Leon Shargorodsky" wrote:
sql
Labels:
advance,
bases,
database,
microsoft,
mysql,
oracle,
production,
schedule,
scheduling,
scriptevery,
scripting,
server,
sql
Friday, March 23, 2012
Scheduled Task to restore Database ?
There is a requirement to restore the production database to testing
database regularly. It can be done manually with no big problem except
changing the logins.
However, someone suggests scheduling a task to restore the production
database to testing database on every Sunday. Is it possible to do so ?
Thanking you in anticipation.
Robert wrote:
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
You can create a SQL script and then schedule this to run every Sunday.
It might also be necessary to add a step in the script to disconnect any
user sessions before you start the restore. Otherwise the Restore will
fail if there're users connected.
Regards
Steen
|||Robert
Well , in our company we do it every month , so prior to RESTORE to
developing server we backup an existing database (on Developing Server) and
the drop it
Yes , you can create an job to perform it , however I do it by running
stored procedure that does restore operation from QA
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:%23dqYBjLIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
|||Dear Steen,
Do you have any idea where can I find samples of those scripts - disconnect
user and restore ?
Thanks
"Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
> Robert wrote:
> You can create a SQL script and then schedule this to run every Sunday.
> It might also be necessary to add a step in the script to disconnect any
> user sessions before you start the restore. Otherwise the Restore will
> fail if there're users connected.
>
> Regards
> Steen
|||> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
Below is an example (SQL 2000). See the Books Online for syntax details.
USE master
ALTER DATABASE MyTestDatabase
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
RESTORE DATABASE MyTestDatabase
FROM DISK='C:\Backups\MyProductionDatabase.bak'
WITH
MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
--login/user fixup here
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
> Dear Steen,
> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
> Thanks
> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>
|||Dear Dan,
Thank you for your advice and it works properly.
I have set up a job to with 2 steps - The first one is to make the backup of
the Production DB and the second one is to restore to the Testing DB.
I would like to make 2 enhancement and would like to seek your advice.
1) When I "Set Single User", I find that if someone is connected, it fails.
Is it possible to disconnect users connected to the Testing Database ?
2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
like to include it in Step 3 ?
Thanks again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
> Below is an example (SQL 2000). See the Books Online for syntax details.
> USE master
> ALTER DATABASE MyTestDatabase
> SET SINGLE_USER
> WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE MyTestDatabase
> FROM DISK='C:\Backups\MyProductionDatabase.bak'
> WITH
> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
> MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
> --login/user fixup here
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>
|||> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should kill
all connections to that database except your own (you can issue the command
from master). However, it might take a little time for the killed
transaction(s) to rollback. In that case, you might try including the
following between the ALTER DATABASE and RESTORE:
--wait for all database locks to be released
WHILE EXISTS
(
SELECT *
FROM syslocks
WHERE dbid = DB_ID('MyDatabase')
)
BEGIN
WAITFOR DELAY '00:00:01'
END
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
You can include the delete command (DEL
"C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
also delete the file from an ActiveX script or T-SQL xp_cmdshell command but
those methods are more complex than needed for this simple requirement.
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
> Dear Dan,
> Thank you for your advice and it works properly.
> I have set up a job to with 2 steps - The first one is to make the backup
> of the Production DB and the second one is to restore to the Testing DB.
> I would like to make 2 enhancement and would like to seek your advice.
> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
> Thanks again.
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>
|||Dear Dan,
Thank you for your advice.
When I try to disconnect yesterday, maybe I have already kicked users out
but I am not aware. I still get the error message that it cannot be set to
single user - maybe because I am still connecting to it.
I will try your suggestion tomorrow.
Thanks for your advice again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%235jXFoaIGHA.516@.TK2MSFTNGP15.phx.gbl...
> Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should
> kill all connections to that database except your own (you can issue the
> command from master). However, it might take a little time for the killed
> transaction(s) to rollback. In that case, you might try including the
> following between the ALTER DATABASE and RESTORE:
> --wait for all database locks to be released
> WHILE EXISTS
> (
> SELECT *
> FROM syslocks
> WHERE dbid = DB_ID('MyDatabase')
> )
> BEGIN
> WAITFOR DELAY '00:00:01'
> END
>
> You can include the delete command (DEL
> "C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
> also delete the file from an ActiveX script or T-SQL xp_cmdshell command
> but those methods are more complex than needed for this simple
> requirement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
>
database regularly. It can be done manually with no big problem except
changing the logins.
However, someone suggests scheduling a task to restore the production
database to testing database on every Sunday. Is it possible to do so ?
Thanking you in anticipation.
Robert wrote:
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
You can create a SQL script and then schedule this to run every Sunday.
It might also be necessary to add a step in the script to disconnect any
user sessions before you start the restore. Otherwise the Restore will
fail if there're users connected.
Regards
Steen
|||Robert
Well , in our company we do it every month , so prior to RESTORE to
developing server we backup an existing database (on Developing Server) and
the drop it
Yes , you can create an job to perform it , however I do it by running
stored procedure that does restore operation from QA
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:%23dqYBjLIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
|||Dear Steen,
Do you have any idea where can I find samples of those scripts - disconnect
user and restore ?
Thanks
"Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
> Robert wrote:
> You can create a SQL script and then schedule this to run every Sunday.
> It might also be necessary to add a step in the script to disconnect any
> user sessions before you start the restore. Otherwise the Restore will
> fail if there're users connected.
>
> Regards
> Steen
|||> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
Below is an example (SQL 2000). See the Books Online for syntax details.
USE master
ALTER DATABASE MyTestDatabase
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
RESTORE DATABASE MyTestDatabase
FROM DISK='C:\Backups\MyProductionDatabase.bak'
WITH
MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
--login/user fixup here
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
> Dear Steen,
> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
> Thanks
> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>
|||Dear Dan,
Thank you for your advice and it works properly.
I have set up a job to with 2 steps - The first one is to make the backup of
the Production DB and the second one is to restore to the Testing DB.
I would like to make 2 enhancement and would like to seek your advice.
1) When I "Set Single User", I find that if someone is connected, it fails.
Is it possible to disconnect users connected to the Testing Database ?
2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
like to include it in Step 3 ?
Thanks again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
> Below is an example (SQL 2000). See the Books Online for syntax details.
> USE master
> ALTER DATABASE MyTestDatabase
> SET SINGLE_USER
> WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE MyTestDatabase
> FROM DISK='C:\Backups\MyProductionDatabase.bak'
> WITH
> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
> MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
> --login/user fixup here
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>
|||> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should kill
all connections to that database except your own (you can issue the command
from master). However, it might take a little time for the killed
transaction(s) to rollback. In that case, you might try including the
following between the ALTER DATABASE and RESTORE:
--wait for all database locks to be released
WHILE EXISTS
(
SELECT *
FROM syslocks
WHERE dbid = DB_ID('MyDatabase')
)
BEGIN
WAITFOR DELAY '00:00:01'
END
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
You can include the delete command (DEL
"C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
also delete the file from an ActiveX script or T-SQL xp_cmdshell command but
those methods are more complex than needed for this simple requirement.
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
> Dear Dan,
> Thank you for your advice and it works properly.
> I have set up a job to with 2 steps - The first one is to make the backup
> of the Production DB and the second one is to restore to the Testing DB.
> I would like to make 2 enhancement and would like to seek your advice.
> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
> Thanks again.
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>
|||Dear Dan,
Thank you for your advice.
When I try to disconnect yesterday, maybe I have already kicked users out
but I am not aware. I still get the error message that it cannot be set to
single user - maybe because I am still connecting to it.
I will try your suggestion tomorrow.
Thanks for your advice again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%235jXFoaIGHA.516@.TK2MSFTNGP15.phx.gbl...
> Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should
> kill all connections to that database except your own (you can issue the
> command from master). However, it might take a little time for the killed
> transaction(s) to rollback. In that case, you might try including the
> following between the ALTER DATABASE and RESTORE:
> --wait for all database locks to be released
> WHILE EXISTS
> (
> SELECT *
> FROM syslocks
> WHERE dbid = DB_ID('MyDatabase')
> )
> BEGIN
> WAITFOR DELAY '00:00:01'
> END
>
> You can include the delete command (DEL
> "C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
> also delete the file from an ActiveX script or T-SQL xp_cmdshell command
> but those methods are more complex than needed for this simple
> requirement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
>
Labels:
database,
exceptchanging,
manually,
microsoft,
mysql,
oracle,
production,
regularly,
requirement,
restore,
scheduled,
server,
sql,
task,
testingdatabase
Scheduled Task to restore Database ?
There is a requirement to restore the production database to testing
database regularly. It can be done manually with no big problem except
changing the logins.
However, someone suggests scheduling a task to restore the production
database to testing database on every Sunday. Is it possible to do so ?
Thanking you in anticipation.Robert wrote:
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
You can create a SQL script and then schedule this to run every Sunday.
It might also be necessary to add a step in the script to disconnect any
user sessions before you start the restore. Otherwise the Restore will
fail if there're users connected.
Regards
Steen|||Robert
Well , in our company we do it every month , so prior to RESTORE to
developing server we backup an existing database (on Developing Server) and
the drop it
Yes , you can create an job to perform it , however I do it by running
stored procedure that does restore operation from QA
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:%23dqYBjLIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>|||Dear Steen,
Do you have any idea where can I find samples of those scripts - disconnect
user and restore ?
Thanks
"Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem except
>> changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so ?
>> Thanking you in anticipation.
> You can create a SQL script and then schedule this to run every Sunday.
> It might also be necessary to add a step in the script to disconnect any
> user sessions before you start the restore. Otherwise the Restore will
> fail if there're users connected.
>
> Regards
> Steen|||> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
Below is an example (SQL 2000). See the Books Online for syntax details.
USE master
ALTER DATABASE MyTestDatabase
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
RESTORE DATABASE MyTestDatabase
FROM DISK='C:\Backups\MyProductionDatabase.bak'
WITH
MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
--login/user fixup here
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
> Dear Steen,
> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
> Thanks
> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem except
>> changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every Sunday.
>> It might also be necessary to add a step in the script to disconnect any
>> user sessions before you start the restore. Otherwise the Restore will
>> fail if there're users connected.
>>
>> Regards
>> Steen
>|||Dear Dan,
Thank you for your advice and it works properly.
I have set up a job to with 2 steps - The first one is to make the backup of
the Production DB and the second one is to restore to the Testing DB.
I would like to make 2 enhancement and would like to seek your advice.
1) When I "Set Single User", I find that if someone is connected, it fails.
Is it possible to disconnect users connected to the Testing Database ?
2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
like to include it in Step 3 ?
Thanks again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
> Below is an example (SQL 2000). See the Books Online for syntax details.
> USE master
> ALTER DATABASE MyTestDatabase
> SET SINGLE_USER
> WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE MyTestDatabase
> FROM DISK='C:\Backups\MyProductionDatabase.bak'
> WITH
> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
> MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
> --login/user fixup here
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>> Dear Steen,
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Thanks
>> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
>> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem except
>> changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so
>> ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every Sunday.
>> It might also be necessary to add a step in the script to disconnect any
>> user sessions before you start the restore. Otherwise the Restore will
>> fail if there're users connected.
>>
>> Regards
>> Steen
>>
>|||> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should kill
all connections to that database except your own (you can issue the command
from master). However, it might take a little time for the killed
transaction(s) to rollback. In that case, you might try including the
following between the ALTER DATABASE and RESTORE:
--wait for all database locks to be released
WHILE EXISTS
(
SELECT *
FROM syslocks
WHERE dbid = DB_ID('MyDatabase')
)
BEGIN
WAITFOR DELAY '00:00:01'
END
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
You can include the delete command (DEL
"C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
also delete the file from an ActiveX script or T-SQL xp_cmdshell command but
those methods are more complex than needed for this simple requirement.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
> Dear Dan,
> Thank you for your advice and it works properly.
> I have set up a job to with 2 steps - The first one is to make the backup
> of the Production DB and the second one is to restore to the Testing DB.
> I would like to make 2 enhancement and would like to seek your advice.
> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
> Thanks again.
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Below is an example (SQL 2000). See the Books Online for syntax details.
>> USE master
>> ALTER DATABASE MyTestDatabase
>> SET SINGLE_USER
>> WITH ROLLBACK IMMEDIATE
>> RESTORE DATABASE MyTestDatabase
>> FROM DISK='C:\Backups\MyProductionDatabase.bak'
>> WITH
>> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
>> MOVE 'MyProductionDatabase_Log' TO
>> 'F:\LogFiles\MyTestDatabase_Log.ldf'
>> --login/user fixup here
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "Robert" <Robert@.discussions.microsoft.com> wrote in message
>> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>> Dear Steen,
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Thanks
>> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
>> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem
>> except changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so
>> ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every Sunday.
>> It might also be necessary to add a step in the script to disconnect
>> any user sessions before you start the restore. Otherwise the Restore
>> will fail if there're users connected.
>>
>> Regards
>> Steen
>>
>>
>|||Dear Dan,
Thank you for your advice.
When I try to disconnect yesterday, maybe I have already kicked users out
but I am not aware. I still get the error message that it cannot be set to
single user - maybe because I am still connecting to it.
I will try your suggestion tomorrow.
Thanks for your advice again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%235jXFoaIGHA.516@.TK2MSFTNGP15.phx.gbl...
>> 1) When I "Set Single User", I find that if someone is connected, it
>> fails. Is it possible to disconnect users connected to the Testing
>> Database ?
> Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should
> kill all connections to that database except your own (you can issue the
> command from master). However, it might take a little time for the killed
> transaction(s) to rollback. In that case, you might try including the
> following between the ALTER DATABASE and RESTORE:
> --wait for all database locks to be released
> WHILE EXISTS
> (
> SELECT *
> FROM syslocks
> WHERE dbid = DB_ID('MyDatabase')
> )
> BEGIN
> WAITFOR DELAY '00:00:01'
> END
>> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
>> like to include it in Step 3 ?
> You can include the delete command (DEL
> "C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
> also delete the file from an ActiveX script or T-SQL xp_cmdshell command
> but those methods are more complex than needed for this simple
> requirement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
>> Dear Dan,
>> Thank you for your advice and it works properly.
>> I have set up a job to with 2 steps - The first one is to make the backup
>> of the Production DB and the second one is to restore to the Testing DB.
>> I would like to make 2 enhancement and would like to seek your advice.
>> 1) When I "Set Single User", I find that if someone is connected, it
>> fails. Is it possible to disconnect users connected to the Testing
>> Database ?
>> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
>> like to include it in Step 3 ?
>> Thanks again.
>>
>> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
>> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Below is an example (SQL 2000). See the Books Online for syntax
>> details.
>> USE master
>> ALTER DATABASE MyTestDatabase
>> SET SINGLE_USER
>> WITH ROLLBACK IMMEDIATE
>> RESTORE DATABASE MyTestDatabase
>> FROM DISK='C:\Backups\MyProductionDatabase.bak'
>> WITH
>> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
>> MOVE 'MyProductionDatabase_Log' TO
>> 'F:\LogFiles\MyTestDatabase_Log.ldf'
>> --login/user fixup here
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "Robert" <Robert@.discussions.microsoft.com> wrote in message
>> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>> Dear Steen,
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Thanks
>> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
>> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem
>> except changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do
>> so ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every
>> Sunday.
>> It might also be necessary to add a step in the script to disconnect
>> any user sessions before you start the restore. Otherwise the Restore
>> will fail if there're users connected.
>>
>> Regards
>> Steen
>>
>>
>>
>
database regularly. It can be done manually with no big problem except
changing the logins.
However, someone suggests scheduling a task to restore the production
database to testing database on every Sunday. Is it possible to do so ?
Thanking you in anticipation.Robert wrote:
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
You can create a SQL script and then schedule this to run every Sunday.
It might also be necessary to add a step in the script to disconnect any
user sessions before you start the restore. Otherwise the Restore will
fail if there're users connected.
Regards
Steen|||Robert
Well , in our company we do it every month , so prior to RESTORE to
developing server we backup an existing database (on Developing Server) and
the drop it
Yes , you can create an job to perform it , however I do it by running
stored procedure that does restore operation from QA
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:%23dqYBjLIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>|||Dear Steen,
Do you have any idea where can I find samples of those scripts - disconnect
user and restore ?
Thanks
"Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem except
>> changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so ?
>> Thanking you in anticipation.
> You can create a SQL script and then schedule this to run every Sunday.
> It might also be necessary to add a step in the script to disconnect any
> user sessions before you start the restore. Otherwise the Restore will
> fail if there're users connected.
>
> Regards
> Steen|||> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
Below is an example (SQL 2000). See the Books Online for syntax details.
USE master
ALTER DATABASE MyTestDatabase
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
RESTORE DATABASE MyTestDatabase
FROM DISK='C:\Backups\MyProductionDatabase.bak'
WITH
MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
--login/user fixup here
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
> Dear Steen,
> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
> Thanks
> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem except
>> changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every Sunday.
>> It might also be necessary to add a step in the script to disconnect any
>> user sessions before you start the restore. Otherwise the Restore will
>> fail if there're users connected.
>>
>> Regards
>> Steen
>|||Dear Dan,
Thank you for your advice and it works properly.
I have set up a job to with 2 steps - The first one is to make the backup of
the Production DB and the second one is to restore to the Testing DB.
I would like to make 2 enhancement and would like to seek your advice.
1) When I "Set Single User", I find that if someone is connected, it fails.
Is it possible to disconnect users connected to the Testing Database ?
2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
like to include it in Step 3 ?
Thanks again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
> Below is an example (SQL 2000). See the Books Online for syntax details.
> USE master
> ALTER DATABASE MyTestDatabase
> SET SINGLE_USER
> WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE MyTestDatabase
> FROM DISK='C:\Backups\MyProductionDatabase.bak'
> WITH
> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
> MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
> --login/user fixup here
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>> Dear Steen,
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Thanks
>> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
>> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem except
>> changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so
>> ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every Sunday.
>> It might also be necessary to add a step in the script to disconnect any
>> user sessions before you start the restore. Otherwise the Restore will
>> fail if there're users connected.
>>
>> Regards
>> Steen
>>
>|||> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should kill
all connections to that database except your own (you can issue the command
from master). However, it might take a little time for the killed
transaction(s) to rollback. In that case, you might try including the
following between the ALTER DATABASE and RESTORE:
--wait for all database locks to be released
WHILE EXISTS
(
SELECT *
FROM syslocks
WHERE dbid = DB_ID('MyDatabase')
)
BEGIN
WAITFOR DELAY '00:00:01'
END
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
You can include the delete command (DEL
"C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
also delete the file from an ActiveX script or T-SQL xp_cmdshell command but
those methods are more complex than needed for this simple requirement.
--
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
> Dear Dan,
> Thank you for your advice and it works properly.
> I have set up a job to with 2 steps - The first one is to make the backup
> of the Production DB and the second one is to restore to the Testing DB.
> I would like to make 2 enhancement and would like to seek your advice.
> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
> Thanks again.
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Below is an example (SQL 2000). See the Books Online for syntax details.
>> USE master
>> ALTER DATABASE MyTestDatabase
>> SET SINGLE_USER
>> WITH ROLLBACK IMMEDIATE
>> RESTORE DATABASE MyTestDatabase
>> FROM DISK='C:\Backups\MyProductionDatabase.bak'
>> WITH
>> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
>> MOVE 'MyProductionDatabase_Log' TO
>> 'F:\LogFiles\MyTestDatabase_Log.ldf'
>> --login/user fixup here
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "Robert" <Robert@.discussions.microsoft.com> wrote in message
>> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>> Dear Steen,
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Thanks
>> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
>> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem
>> except changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do so
>> ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every Sunday.
>> It might also be necessary to add a step in the script to disconnect
>> any user sessions before you start the restore. Otherwise the Restore
>> will fail if there're users connected.
>>
>> Regards
>> Steen
>>
>>
>|||Dear Dan,
Thank you for your advice.
When I try to disconnect yesterday, maybe I have already kicked users out
but I am not aware. I still get the error message that it cannot be set to
single user - maybe because I am still connecting to it.
I will try your suggestion tomorrow.
Thanks for your advice again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%235jXFoaIGHA.516@.TK2MSFTNGP15.phx.gbl...
>> 1) When I "Set Single User", I find that if someone is connected, it
>> fails. Is it possible to disconnect users connected to the Testing
>> Database ?
> Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should
> kill all connections to that database except your own (you can issue the
> command from master). However, it might take a little time for the killed
> transaction(s) to rollback. In that case, you might try including the
> following between the ALTER DATABASE and RESTORE:
> --wait for all database locks to be released
> WHILE EXISTS
> (
> SELECT *
> FROM syslocks
> WHERE dbid = DB_ID('MyDatabase')
> )
> BEGIN
> WAITFOR DELAY '00:00:01'
> END
>> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
>> like to include it in Step 3 ?
> You can include the delete command (DEL
> "C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
> also delete the file from an ActiveX script or T-SQL xp_cmdshell command
> but those methods are more complex than needed for this simple
> requirement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
>> Dear Dan,
>> Thank you for your advice and it works properly.
>> I have set up a job to with 2 steps - The first one is to make the backup
>> of the Production DB and the second one is to restore to the Testing DB.
>> I would like to make 2 enhancement and would like to seek your advice.
>> 1) When I "Set Single User", I find that if someone is connected, it
>> fails. Is it possible to disconnect users connected to the Testing
>> Database ?
>> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
>> like to include it in Step 3 ?
>> Thanks again.
>>
>> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
>> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Below is an example (SQL 2000). See the Books Online for syntax
>> details.
>> USE master
>> ALTER DATABASE MyTestDatabase
>> SET SINGLE_USER
>> WITH ROLLBACK IMMEDIATE
>> RESTORE DATABASE MyTestDatabase
>> FROM DISK='C:\Backups\MyProductionDatabase.bak'
>> WITH
>> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
>> MOVE 'MyProductionDatabase_Log' TO
>> 'F:\LogFiles\MyTestDatabase_Log.ldf'
>> --login/user fixup here
>> --
>> Hope this helps.
>> Dan Guzman
>> SQL Server MVP
>> "Robert" <Robert@.discussions.microsoft.com> wrote in message
>> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>> Dear Steen,
>> Do you have any idea where can I find samples of those scripts -
>> disconnect user and restore ?
>> Thanks
>> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
>> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>> Robert wrote:
>> There is a requirement to restore the production database to testing
>> database regularly. It can be done manually with no big problem
>> except changing the logins.
>> However, someone suggests scheduling a task to restore the production
>> database to testing database on every Sunday. Is it possible to do
>> so ?
>> Thanking you in anticipation.
>> You can create a SQL script and then schedule this to run every
>> Sunday.
>> It might also be necessary to add a step in the script to disconnect
>> any user sessions before you start the restore. Otherwise the Restore
>> will fail if there're users connected.
>>
>> Regards
>> Steen
>>
>>
>>
>
Scheduled Task to restore Database ?
There is a requirement to restore the production database to testing
database regularly. It can be done manually with no big problem except
changing the logins.
However, someone suggests scheduling a task to restore the production
database to testing database on every Sunday. Is it possible to do so ?
Thanking you in anticipation.Robert wrote:
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
You can create a SQL script and then schedule this to run every Sunday.
It might also be necessary to add a step in the script to disconnect any
user sessions before you start the restore. Otherwise the Restore will
fail if there're users connected.
Regards
Steen|||Robert
Well , in our company we do it every month , so prior to RESTORE to
developing server we backup an existing database (on Developing Server) and
the drop it
Yes , you can create an job to perform it , however I do it by running
stored procedure that does restore operation from QA
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:%23dqYBjLIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>|||Dear Steen,
Do you have any idea where can I find samples of those scripts - disconnect
user and restore ?
Thanks
"Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
> Robert wrote:
> You can create a SQL script and then schedule this to run every Sunday.
> It might also be necessary to add a step in the script to disconnect any
> user sessions before you start the restore. Otherwise the Restore will
> fail if there're users connected.
>
> Regards
> Steen|||> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
Below is an example (SQL 2000). See the Books Online for syntax details.
USE master
ALTER DATABASE MyTestDatabase
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
RESTORE DATABASE MyTestDatabase
FROM DISK='C:\Backups\MyProductionDatabase.bak'
WITH
MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
--login/user fixup here
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
> Dear Steen,
> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
> Thanks
> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>|||Dear Dan,
Thank you for your advice and it works properly.
I have set up a job to with 2 steps - The first one is to make the backup of
the Production DB and the second one is to restore to the Testing DB.
I would like to make 2 enhancement and would like to seek your advice.
1) When I "Set Single User", I find that if someone is connected, it fails.
Is it possible to disconnect users connected to the Testing Database ?
2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
like to include it in Step 3 ?
Thanks again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
> Below is an example (SQL 2000). See the Books Online for syntax details.
> USE master
> ALTER DATABASE MyTestDatabase
> SET SINGLE_USER
> WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE MyTestDatabase
> FROM DISK='C:\Backups\MyProductionDatabase.bak'
> WITH
> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
> MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
> --login/user fixup here
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>|||> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should kill
all connections to that database except your own (you can issue the command
from master). However, it might take a little time for the killed
transaction(s) to rollback. In that case, you might try including the
following between the ALTER DATABASE and RESTORE:
--wait for all database locks to be released
WHILE EXISTS
(
SELECT *
FROM syslocks
WHERE dbid = DB_ID('MyDatabase')
)
BEGIN
WAITFOR DELAY '00:00:01'
END
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
You can include the delete command (DEL
"C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
also delete the file from an ActiveX script or T-SQL xp_cmdshell command but
those methods are more complex than needed for this simple requirement.
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
> Dear Dan,
> Thank you for your advice and it works properly.
> I have set up a job to with 2 steps - The first one is to make the backup
> of the Production DB and the second one is to restore to the Testing DB.
> I would like to make 2 enhancement and would like to seek your advice.
> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
> Thanks again.
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>|||Dear Dan,
Thank you for your advice.
When I try to disconnect yesterday, maybe I have already kicked users out
but I am not aware. I still get the error message that it cannot be set to
single user - maybe because I am still connecting to it.
I will try your suggestion tomorrow.
Thanks for your advice again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%235jXFoaIGHA.516@.TK2MSFTNGP15.phx.gbl...
> Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should
> kill all connections to that database except your own (you can issue the
> command from master). However, it might take a little time for the killed
> transaction(s) to rollback. In that case, you might try including the
> following between the ALTER DATABASE and RESTORE:
> --wait for all database locks to be released
> WHILE EXISTS
> (
> SELECT *
> FROM syslocks
> WHERE dbid = DB_ID('MyDatabase')
> )
> BEGIN
> WAITFOR DELAY '00:00:01'
> END
>
> You can include the delete command (DEL
> "C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
> also delete the file from an ActiveX script or T-SQL xp_cmdshell command
> but those methods are more complex than needed for this simple
> requirement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
>
database regularly. It can be done manually with no big problem except
changing the logins.
However, someone suggests scheduling a task to restore the production
database to testing database on every Sunday. Is it possible to do so ?
Thanking you in anticipation.Robert wrote:
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>
You can create a SQL script and then schedule this to run every Sunday.
It might also be necessary to add a step in the script to disconnect any
user sessions before you start the restore. Otherwise the Restore will
fail if there're users connected.
Regards
Steen|||Robert
Well , in our company we do it every month , so prior to RESTORE to
developing server we backup an existing database (on Developing Server) and
the drop it
Yes , you can create an job to perform it , however I do it by running
stored procedure that does restore operation from QA
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:%23dqYBjLIGHA.3144@.TK2MSFTNGP11.phx.gbl...
> There is a requirement to restore the production database to testing
> database regularly. It can be done manually with no big problem except
> changing the logins.
> However, someone suggests scheduling a task to restore the production
> database to testing database on every Sunday. Is it possible to do so ?
> Thanking you in anticipation.
>|||Dear Steen,
Do you have any idea where can I find samples of those scripts - disconnect
user and restore ?
Thanks
"Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
> Robert wrote:
> You can create a SQL script and then schedule this to run every Sunday.
> It might also be necessary to add a step in the script to disconnect any
> user sessions before you start the restore. Otherwise the Restore will
> fail if there're users connected.
>
> Regards
> Steen|||> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
Below is an example (SQL 2000). See the Books Online for syntax details.
USE master
ALTER DATABASE MyTestDatabase
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE
RESTORE DATABASE MyTestDatabase
FROM DISK='C:\Backups\MyProductionDatabase.bak'
WITH
MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
--login/user fixup here
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
> Dear Steen,
> Do you have any idea where can I find samples of those scripts -
> disconnect user and restore ?
> Thanks
> "Steen Persson (DK)" <spe@.REMOVEdatea.dk> wrote in message
> news:ugQw8oLIGHA.1424@.TK2MSFTNGP12.phx.gbl...
>|||Dear Dan,
Thank you for your advice and it works properly.
I have set up a job to with 2 steps - The first one is to make the backup of
the Production DB and the second one is to restore to the Testing DB.
I would like to make 2 enhancement and would like to seek your advice.
1) When I "Set Single User", I find that if someone is connected, it fails.
Is it possible to disconnect users connected to the Testing Database ?
2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
like to include it in Step 3 ?
Thanks again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
> Below is an example (SQL 2000). See the Books Online for syntax details.
> USE master
> ALTER DATABASE MyTestDatabase
> SET SINGLE_USER
> WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE MyTestDatabase
> FROM DISK='C:\Backups\MyProductionDatabase.bak'
> WITH
> MOVE 'MyProductionDatabase' TO 'E:\DataFiles\MyTestDatabase.mdf',
> MOVE 'MyProductionDatabase_Log' TO 'F:\LogFiles\MyTestDatabase_Log.ldf'
> --login/user fixup here
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:Okkt8YNIGHA.3700@.TK2MSFTNGP15.phx.gbl...
>|||> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should kill
all connections to that database except your own (you can issue the command
from master). However, it might take a little time for the killed
transaction(s) to rollback. In that case, you might try including the
following between the ALTER DATABASE and RESTORE:
--wait for all database locks to be released
WHILE EXISTS
(
SELECT *
FROM syslocks
WHERE dbid = DB_ID('MyDatabase')
)
BEGIN
WAITFOR DELAY '00:00:01'
END
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
You can include the delete command (DEL
"C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
also delete the file from an ActiveX script or T-SQL xp_cmdshell command but
those methods are more complex than needed for this simple requirement.
Hope this helps.
Dan Guzman
SQL Server MVP
"Robert" <Robert@.discussions.microsoft.com> wrote in message
news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
> Dear Dan,
> Thank you for your advice and it works properly.
> I have set up a job to with 2 steps - The first one is to make the backup
> of the Production DB and the second one is to restore to the Testing DB.
> I would like to make 2 enhancement and would like to seek your advice.
> 1) When I "Set Single User", I find that if someone is connected, it
> fails. Is it possible to disconnect users connected to the Testing
> Database ?
> 2) How can I delete the 'C:\Backups\MyProductionDatabase.bak' if I would
> like to include it in Step 3 ?
> Thanks again.
>
> "Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
> news:eELyPDOIGHA.2472@.TK2MSFTNGP10.phx.gbl...
>|||Dear Dan,
Thank you for your advice.
When I try to disconnect yesterday, maybe I have already kicked users out
but I am not aware. I still get the error message that it cannot be set to
single user - maybe because I am still connecting to it.
I will try your suggestion tomorrow.
Thanks for your advice again.
"Dan Guzman" <guzmanda@.nospam-online.sbcglobal.net> wrote in message
news:%235jXFoaIGHA.516@.TK2MSFTNGP15.phx.gbl...
> Did you also include the 'WITH ROLLBACK IMMEDIATE' option? That should
> kill all connections to that database except your own (you can issue the
> command from master). However, it might take a little time for the killed
> transaction(s) to rollback. In that case, you might try including the
> following between the ALTER DATABASE and RESTORE:
> --wait for all database locks to be released
> WHILE EXISTS
> (
> SELECT *
> FROM syslocks
> WHERE dbid = DB_ID('MyDatabase')
> )
> BEGIN
> WAITFOR DELAY '00:00:01'
> END
>
> You can include the delete command (DEL
> "C:\Backups\MyProductionDatabase.bak") in a CmdExec job step. You could
> also delete the file from an ActiveX script or T-SQL xp_cmdshell command
> but those methods are more complex than needed for this simple
> requirement.
> --
> Hope this helps.
> Dan Guzman
> SQL Server MVP
> "Robert" <Robert@.discussions.microsoft.com> wrote in message
> news:uB4al1YIGHA.1132@.TK2MSFTNGP10.phx.gbl...
>
Labels:
database,
exceptchanging,
manually,
microsoft,
mysql,
oracle,
production,
regularly,
requirement,
restore,
scheduled,
server,
sql,
task,
testingdatabase
Wednesday, March 21, 2012
scheduled server side trace - not working!
Hi,
I am looking to schedule a server side trace for a production server.
I need to capture all events on the server from 2AM until 9AM. The
server is automatically rebooted at 12-1AM so I have scripted a trace
and wrapped it in a stored proc. A SQL Job is scheduled for 2AM to run
the trace. When I check the trace file in the morning it doesn't show
the correct data, it shows only an hours worth of data for the
afternoon. The SQL Job runs with non errors.
Here's the file:
---
CREATE PROCEDURE dbo.pr_CCDTRACE
AS
/ ****************************************
************/
/* Created by: SQL Profiler */
/* Date: 05/10/2005 15:48:30 */
/ ****************************************
************/
-- Create a Queue
declare @.rc int
declare @.TraceID int
declare @.maxfilesize bigint
declare @.DateTime datetime
set @.DateTime = '2005-10-06 10:00:00.000'
set @.maxfilesize = 50
exec @.rc = sp_trace_create @.TraceID output, 0, N'C:\CDDTrace_06102005',
@.maxfilesize, @.Datetime
if (@.rc != 0) goto error
declare @.on bit
set @.on = 1
exec sp_trace_setevent @.TraceID, 10, 1, @.on
exec sp_trace_setevent @.TraceID, 10, 6, @.on
exec sp_trace_setevent @.TraceID, 10, 9, @.on
exec sp_trace_setevent @.TraceID, 10, 10, @.on
exec sp_trace_setevent @.TraceID, 10, 11, @.on
exec sp_trace_setevent @.TraceID, 10, 12, @.on
exec sp_trace_setevent @.TraceID, 10, 13, @.on
exec sp_trace_setevent @.TraceID, 10, 14, @.on
exec sp_trace_setevent @.TraceID, 10, 15, @.on
exec sp_trace_setevent @.TraceID, 10, 16, @.on
exec sp_trace_setevent @.TraceID, 10, 17, @.on
exec sp_trace_setevent @.TraceID, 10, 18, @.on
exec sp_trace_setevent @.TraceID, 12, 1, @.on
exec sp_trace_setevent @.TraceID, 12, 6, @.on
exec sp_trace_setevent @.TraceID, 12, 9, @.on
exec sp_trace_setevent @.TraceID, 12, 10, @.on
exec sp_trace_setevent @.TraceID, 12, 11, @.on
exec sp_trace_setevent @.TraceID, 12, 12, @.on
exec sp_trace_setevent @.TraceID, 12, 13, @.on
exec sp_trace_setevent @.TraceID, 12, 14, @.on
exec sp_trace_setevent @.TraceID, 12, 15, @.on
exec sp_trace_setevent @.TraceID, 12, 16, @.on
exec sp_trace_setevent @.TraceID, 12, 17, @.on
exec sp_trace_setevent @.TraceID, 12, 18, @.on
exec sp_trace_setevent @.TraceID, 50, 1, @.on
exec sp_trace_setevent @.TraceID, 50, 6, @.on
exec sp_trace_setevent @.TraceID, 50, 9, @.on
exec sp_trace_setevent @.TraceID, 50, 10, @.on
exec sp_trace_setevent @.TraceID, 50, 11, @.on
exec sp_trace_setevent @.TraceID, 50, 12, @.on
exec sp_trace_setevent @.TraceID, 50, 13, @.on
exec sp_trace_setevent @.TraceID, 50, 14, @.on
exec sp_trace_setevent @.TraceID, 50, 15, @.on
exec sp_trace_setevent @.TraceID, 50, 16, @.on
exec sp_trace_setevent @.TraceID, 50, 17, @.on
exec sp_trace_setevent @.TraceID, 50, 18, @.on
exec sp_trace_setevent @.TraceID, 53, 1, @.on
exec sp_trace_setevent @.TraceID, 53, 6, @.on
exec sp_trace_setevent @.TraceID, 53, 9, @.on
exec sp_trace_setevent @.TraceID, 53, 10, @.on
exec sp_trace_setevent @.TraceID, 53, 11, @.on
exec sp_trace_setevent @.TraceID, 53, 12, @.on
exec sp_trace_setevent @.TraceID, 53, 13, @.on
exec sp_trace_setevent @.TraceID, 53, 14, @.on
exec sp_trace_setevent @.TraceID, 53, 15, @.on
exec sp_trace_setevent @.TraceID, 53, 16, @.on
exec sp_trace_setevent @.TraceID, 53, 17, @.on
exec sp_trace_setevent @.TraceID, 53, 18, @.on
exec sp_trace_setevent @.TraceID, 78, 1, @.on
exec sp_trace_setevent @.TraceID, 78, 6, @.on
exec sp_trace_setevent @.TraceID, 78, 9, @.on
exec sp_trace_setevent @.TraceID, 78, 10, @.on
exec sp_trace_setevent @.TraceID, 78, 11, @.on
exec sp_trace_setevent @.TraceID, 78, 12, @.on
exec sp_trace_setevent @.TraceID, 78, 13, @.on
exec sp_trace_setevent @.TraceID, 78, 14, @.on
exec sp_trace_setevent @.TraceID, 78, 15, @.on
exec sp_trace_setevent @.TraceID, 78, 16, @.on
exec sp_trace_setevent @.TraceID, 78, 17, @.on
exec sp_trace_setevent @.TraceID, 78, 18, @.on
exec sp_trace_setevent @.TraceID, 81, 1, @.on
exec sp_trace_setevent @.TraceID, 81, 6, @.on
exec sp_trace_setevent @.TraceID, 81, 9, @.on
exec sp_trace_setevent @.TraceID, 81, 10, @.on
exec sp_trace_setevent @.TraceID, 81, 11, @.on
exec sp_trace_setevent @.TraceID, 81, 12, @.on
exec sp_trace_setevent @.TraceID, 81, 13, @.on
exec sp_trace_setevent @.TraceID, 81, 14, @.on
exec sp_trace_setevent @.TraceID, 81, 15, @.on
exec sp_trace_setevent @.TraceID, 81, 16, @.on
exec sp_trace_setevent @.TraceID, 81, 17, @.on
exec sp_trace_setevent @.TraceID, 81, 18, @.on
exec sp_trace_setevent @.TraceID, 92, 1, @.on
exec sp_trace_setevent @.TraceID, 92, 6, @.on
exec sp_trace_setevent @.TraceID, 92, 9, @.on
exec sp_trace_setevent @.TraceID, 92, 10, @.on
exec sp_trace_setevent @.TraceID, 92, 11, @.on
exec sp_trace_setevent @.TraceID, 92, 12, @.on
exec sp_trace_setevent @.TraceID, 92, 13, @.on
exec sp_trace_setevent @.TraceID, 92, 14, @.on
exec sp_trace_setevent @.TraceID, 92, 15, @.on
exec sp_trace_setevent @.TraceID, 92, 16, @.on
exec sp_trace_setevent @.TraceID, 92, 17, @.on
exec sp_trace_setevent @.TraceID, 92, 18, @.on
exec sp_trace_setevent @.TraceID, 94, 1, @.on
exec sp_trace_setevent @.TraceID, 94, 6, @.on
exec sp_trace_setevent @.TraceID, 94, 9, @.on
exec sp_trace_setevent @.TraceID, 94, 10, @.on
exec sp_trace_setevent @.TraceID, 94, 11, @.on
exec sp_trace_setevent @.TraceID, 94, 12, @.on
exec sp_trace_setevent @.TraceID, 94, 13, @.on
exec sp_trace_setevent @.TraceID, 94, 14, @.on
exec sp_trace_setevent @.TraceID, 94, 15, @.on
exec sp_trace_setevent @.TraceID, 94, 16, @.on
exec sp_trace_setevent @.TraceID, 94, 17, @.on
exec sp_trace_setevent @.TraceID, 94, 18, @.on
-- Set the Filters
declare @.intfilter int
declare @.bigintfilter bigint
set @.intfilter = 7
exec sp_trace_setfilter @.TraceID, 3, 1, 0, @.intfilter
exec sp_trace_setfilter @.TraceID, 10, 0, 7, N'SQL Profiler'
-- Set the trace status to start
exec sp_trace_setstatus @.TraceID, 1
-- display trace id for future references
select TraceID=@.TraceID
goto finish
error:
select ErrorCode=@.rc
finish:
GO
---
What am I doing wrong?
TIA
fcYou say that you only have an hours worth of data for the _afternoon_, when
the trace is scheduled to run between 2AM and 10 AM. How does that work? Do
you mean you only have trace data for an hour from 2 AM?
I think that the size for the tracefile you have specified might be to
small. Either specify a larger size than 50 MB, or specify 2 for the options
(2nd parameter) to have the tracefile rollover into a new file when the file
size is exceeded.
Jacco Schalkwijk
SQL Server MVP
"Scott" <quackhandle1975@.yahoo.co.uk> wrote in message
news:1128598736.359959.299190@.o13g2000cwo.googlegroups.com...
> Hi,
> I am looking to schedule a server side trace for a production server.
> I need to capture all events on the server from 2AM until 9AM. The
> server is automatically rebooted at 12-1AM so I have scripted a trace
> and wrapped it in a stored proc. A SQL Job is scheduled for 2AM to run
> the trace. When I check the trace file in the morning it doesn't show
> the correct data, it shows only an hours worth of data for the
> afternoon. The SQL Job runs with non errors.
> Here's the file:
> ---
> CREATE PROCEDURE dbo.pr_CCDTRACE
> AS
> / ****************************************
************/
> /* Created by: SQL Profiler */
> /* Date: 05/10/2005 15:48:30 */
> / ****************************************
************/
>
> -- Create a Queue
> declare @.rc int
> declare @.TraceID int
> declare @.maxfilesize bigint
> declare @.DateTime datetime
> set @.DateTime = '2005-10-06 10:00:00.000'
> set @.maxfilesize = 50
> exec @.rc = sp_trace_create @.TraceID output, 0, N'C:\CDDTrace_06102005',
> @.maxfilesize, @.Datetime
> if (@.rc != 0) goto error
> declare @.on bit
> set @.on = 1
> exec sp_trace_setevent @.TraceID, 10, 1, @.on
> exec sp_trace_setevent @.TraceID, 10, 6, @.on
> exec sp_trace_setevent @.TraceID, 10, 9, @.on
> exec sp_trace_setevent @.TraceID, 10, 10, @.on
> exec sp_trace_setevent @.TraceID, 10, 11, @.on
> exec sp_trace_setevent @.TraceID, 10, 12, @.on
> exec sp_trace_setevent @.TraceID, 10, 13, @.on
> exec sp_trace_setevent @.TraceID, 10, 14, @.on
> exec sp_trace_setevent @.TraceID, 10, 15, @.on
> exec sp_trace_setevent @.TraceID, 10, 16, @.on
> exec sp_trace_setevent @.TraceID, 10, 17, @.on
> exec sp_trace_setevent @.TraceID, 10, 18, @.on
> exec sp_trace_setevent @.TraceID, 12, 1, @.on
> exec sp_trace_setevent @.TraceID, 12, 6, @.on
> exec sp_trace_setevent @.TraceID, 12, 9, @.on
> exec sp_trace_setevent @.TraceID, 12, 10, @.on
> exec sp_trace_setevent @.TraceID, 12, 11, @.on
> exec sp_trace_setevent @.TraceID, 12, 12, @.on
> exec sp_trace_setevent @.TraceID, 12, 13, @.on
> exec sp_trace_setevent @.TraceID, 12, 14, @.on
> exec sp_trace_setevent @.TraceID, 12, 15, @.on
> exec sp_trace_setevent @.TraceID, 12, 16, @.on
> exec sp_trace_setevent @.TraceID, 12, 17, @.on
> exec sp_trace_setevent @.TraceID, 12, 18, @.on
> exec sp_trace_setevent @.TraceID, 50, 1, @.on
> exec sp_trace_setevent @.TraceID, 50, 6, @.on
> exec sp_trace_setevent @.TraceID, 50, 9, @.on
> exec sp_trace_setevent @.TraceID, 50, 10, @.on
> exec sp_trace_setevent @.TraceID, 50, 11, @.on
> exec sp_trace_setevent @.TraceID, 50, 12, @.on
> exec sp_trace_setevent @.TraceID, 50, 13, @.on
> exec sp_trace_setevent @.TraceID, 50, 14, @.on
> exec sp_trace_setevent @.TraceID, 50, 15, @.on
> exec sp_trace_setevent @.TraceID, 50, 16, @.on
> exec sp_trace_setevent @.TraceID, 50, 17, @.on
> exec sp_trace_setevent @.TraceID, 50, 18, @.on
> exec sp_trace_setevent @.TraceID, 53, 1, @.on
> exec sp_trace_setevent @.TraceID, 53, 6, @.on
> exec sp_trace_setevent @.TraceID, 53, 9, @.on
> exec sp_trace_setevent @.TraceID, 53, 10, @.on
> exec sp_trace_setevent @.TraceID, 53, 11, @.on
> exec sp_trace_setevent @.TraceID, 53, 12, @.on
> exec sp_trace_setevent @.TraceID, 53, 13, @.on
> exec sp_trace_setevent @.TraceID, 53, 14, @.on
> exec sp_trace_setevent @.TraceID, 53, 15, @.on
> exec sp_trace_setevent @.TraceID, 53, 16, @.on
> exec sp_trace_setevent @.TraceID, 53, 17, @.on
> exec sp_trace_setevent @.TraceID, 53, 18, @.on
> exec sp_trace_setevent @.TraceID, 78, 1, @.on
> exec sp_trace_setevent @.TraceID, 78, 6, @.on
> exec sp_trace_setevent @.TraceID, 78, 9, @.on
> exec sp_trace_setevent @.TraceID, 78, 10, @.on
> exec sp_trace_setevent @.TraceID, 78, 11, @.on
> exec sp_trace_setevent @.TraceID, 78, 12, @.on
> exec sp_trace_setevent @.TraceID, 78, 13, @.on
> exec sp_trace_setevent @.TraceID, 78, 14, @.on
> exec sp_trace_setevent @.TraceID, 78, 15, @.on
> exec sp_trace_setevent @.TraceID, 78, 16, @.on
> exec sp_trace_setevent @.TraceID, 78, 17, @.on
> exec sp_trace_setevent @.TraceID, 78, 18, @.on
> exec sp_trace_setevent @.TraceID, 81, 1, @.on
> exec sp_trace_setevent @.TraceID, 81, 6, @.on
> exec sp_trace_setevent @.TraceID, 81, 9, @.on
> exec sp_trace_setevent @.TraceID, 81, 10, @.on
> exec sp_trace_setevent @.TraceID, 81, 11, @.on
> exec sp_trace_setevent @.TraceID, 81, 12, @.on
> exec sp_trace_setevent @.TraceID, 81, 13, @.on
> exec sp_trace_setevent @.TraceID, 81, 14, @.on
> exec sp_trace_setevent @.TraceID, 81, 15, @.on
> exec sp_trace_setevent @.TraceID, 81, 16, @.on
> exec sp_trace_setevent @.TraceID, 81, 17, @.on
> exec sp_trace_setevent @.TraceID, 81, 18, @.on
> exec sp_trace_setevent @.TraceID, 92, 1, @.on
> exec sp_trace_setevent @.TraceID, 92, 6, @.on
> exec sp_trace_setevent @.TraceID, 92, 9, @.on
> exec sp_trace_setevent @.TraceID, 92, 10, @.on
> exec sp_trace_setevent @.TraceID, 92, 11, @.on
> exec sp_trace_setevent @.TraceID, 92, 12, @.on
> exec sp_trace_setevent @.TraceID, 92, 13, @.on
> exec sp_trace_setevent @.TraceID, 92, 14, @.on
> exec sp_trace_setevent @.TraceID, 92, 15, @.on
> exec sp_trace_setevent @.TraceID, 92, 16, @.on
> exec sp_trace_setevent @.TraceID, 92, 17, @.on
> exec sp_trace_setevent @.TraceID, 92, 18, @.on
> exec sp_trace_setevent @.TraceID, 94, 1, @.on
> exec sp_trace_setevent @.TraceID, 94, 6, @.on
> exec sp_trace_setevent @.TraceID, 94, 9, @.on
> exec sp_trace_setevent @.TraceID, 94, 10, @.on
> exec sp_trace_setevent @.TraceID, 94, 11, @.on
> exec sp_trace_setevent @.TraceID, 94, 12, @.on
> exec sp_trace_setevent @.TraceID, 94, 13, @.on
> exec sp_trace_setevent @.TraceID, 94, 14, @.on
> exec sp_trace_setevent @.TraceID, 94, 15, @.on
> exec sp_trace_setevent @.TraceID, 94, 16, @.on
> exec sp_trace_setevent @.TraceID, 94, 17, @.on
> exec sp_trace_setevent @.TraceID, 94, 18, @.on
>
> -- Set the Filters
> declare @.intfilter int
> declare @.bigintfilter bigint
> set @.intfilter = 7
> exec sp_trace_setfilter @.TraceID, 3, 1, 0, @.intfilter
> exec sp_trace_setfilter @.TraceID, 10, 0, 7, N'SQL Profiler'
>
> -- Set the trace status to start
> exec sp_trace_setstatus @.TraceID, 1
> -- display trace id for future references
> select TraceID=@.TraceID
> goto finish
> error:
> select ErrorCode=@.rc
> finish:
> GO
> ---
> What am I doing wrong?
> TIA
> fc
>sql
I am looking to schedule a server side trace for a production server.
I need to capture all events on the server from 2AM until 9AM. The
server is automatically rebooted at 12-1AM so I have scripted a trace
and wrapped it in a stored proc. A SQL Job is scheduled for 2AM to run
the trace. When I check the trace file in the morning it doesn't show
the correct data, it shows only an hours worth of data for the
afternoon. The SQL Job runs with non errors.
Here's the file:
---
CREATE PROCEDURE dbo.pr_CCDTRACE
AS
/ ****************************************
************/
/* Created by: SQL Profiler */
/* Date: 05/10/2005 15:48:30 */
/ ****************************************
************/
-- Create a Queue
declare @.rc int
declare @.TraceID int
declare @.maxfilesize bigint
declare @.DateTime datetime
set @.DateTime = '2005-10-06 10:00:00.000'
set @.maxfilesize = 50
exec @.rc = sp_trace_create @.TraceID output, 0, N'C:\CDDTrace_06102005',
@.maxfilesize, @.Datetime
if (@.rc != 0) goto error
declare @.on bit
set @.on = 1
exec sp_trace_setevent @.TraceID, 10, 1, @.on
exec sp_trace_setevent @.TraceID, 10, 6, @.on
exec sp_trace_setevent @.TraceID, 10, 9, @.on
exec sp_trace_setevent @.TraceID, 10, 10, @.on
exec sp_trace_setevent @.TraceID, 10, 11, @.on
exec sp_trace_setevent @.TraceID, 10, 12, @.on
exec sp_trace_setevent @.TraceID, 10, 13, @.on
exec sp_trace_setevent @.TraceID, 10, 14, @.on
exec sp_trace_setevent @.TraceID, 10, 15, @.on
exec sp_trace_setevent @.TraceID, 10, 16, @.on
exec sp_trace_setevent @.TraceID, 10, 17, @.on
exec sp_trace_setevent @.TraceID, 10, 18, @.on
exec sp_trace_setevent @.TraceID, 12, 1, @.on
exec sp_trace_setevent @.TraceID, 12, 6, @.on
exec sp_trace_setevent @.TraceID, 12, 9, @.on
exec sp_trace_setevent @.TraceID, 12, 10, @.on
exec sp_trace_setevent @.TraceID, 12, 11, @.on
exec sp_trace_setevent @.TraceID, 12, 12, @.on
exec sp_trace_setevent @.TraceID, 12, 13, @.on
exec sp_trace_setevent @.TraceID, 12, 14, @.on
exec sp_trace_setevent @.TraceID, 12, 15, @.on
exec sp_trace_setevent @.TraceID, 12, 16, @.on
exec sp_trace_setevent @.TraceID, 12, 17, @.on
exec sp_trace_setevent @.TraceID, 12, 18, @.on
exec sp_trace_setevent @.TraceID, 50, 1, @.on
exec sp_trace_setevent @.TraceID, 50, 6, @.on
exec sp_trace_setevent @.TraceID, 50, 9, @.on
exec sp_trace_setevent @.TraceID, 50, 10, @.on
exec sp_trace_setevent @.TraceID, 50, 11, @.on
exec sp_trace_setevent @.TraceID, 50, 12, @.on
exec sp_trace_setevent @.TraceID, 50, 13, @.on
exec sp_trace_setevent @.TraceID, 50, 14, @.on
exec sp_trace_setevent @.TraceID, 50, 15, @.on
exec sp_trace_setevent @.TraceID, 50, 16, @.on
exec sp_trace_setevent @.TraceID, 50, 17, @.on
exec sp_trace_setevent @.TraceID, 50, 18, @.on
exec sp_trace_setevent @.TraceID, 53, 1, @.on
exec sp_trace_setevent @.TraceID, 53, 6, @.on
exec sp_trace_setevent @.TraceID, 53, 9, @.on
exec sp_trace_setevent @.TraceID, 53, 10, @.on
exec sp_trace_setevent @.TraceID, 53, 11, @.on
exec sp_trace_setevent @.TraceID, 53, 12, @.on
exec sp_trace_setevent @.TraceID, 53, 13, @.on
exec sp_trace_setevent @.TraceID, 53, 14, @.on
exec sp_trace_setevent @.TraceID, 53, 15, @.on
exec sp_trace_setevent @.TraceID, 53, 16, @.on
exec sp_trace_setevent @.TraceID, 53, 17, @.on
exec sp_trace_setevent @.TraceID, 53, 18, @.on
exec sp_trace_setevent @.TraceID, 78, 1, @.on
exec sp_trace_setevent @.TraceID, 78, 6, @.on
exec sp_trace_setevent @.TraceID, 78, 9, @.on
exec sp_trace_setevent @.TraceID, 78, 10, @.on
exec sp_trace_setevent @.TraceID, 78, 11, @.on
exec sp_trace_setevent @.TraceID, 78, 12, @.on
exec sp_trace_setevent @.TraceID, 78, 13, @.on
exec sp_trace_setevent @.TraceID, 78, 14, @.on
exec sp_trace_setevent @.TraceID, 78, 15, @.on
exec sp_trace_setevent @.TraceID, 78, 16, @.on
exec sp_trace_setevent @.TraceID, 78, 17, @.on
exec sp_trace_setevent @.TraceID, 78, 18, @.on
exec sp_trace_setevent @.TraceID, 81, 1, @.on
exec sp_trace_setevent @.TraceID, 81, 6, @.on
exec sp_trace_setevent @.TraceID, 81, 9, @.on
exec sp_trace_setevent @.TraceID, 81, 10, @.on
exec sp_trace_setevent @.TraceID, 81, 11, @.on
exec sp_trace_setevent @.TraceID, 81, 12, @.on
exec sp_trace_setevent @.TraceID, 81, 13, @.on
exec sp_trace_setevent @.TraceID, 81, 14, @.on
exec sp_trace_setevent @.TraceID, 81, 15, @.on
exec sp_trace_setevent @.TraceID, 81, 16, @.on
exec sp_trace_setevent @.TraceID, 81, 17, @.on
exec sp_trace_setevent @.TraceID, 81, 18, @.on
exec sp_trace_setevent @.TraceID, 92, 1, @.on
exec sp_trace_setevent @.TraceID, 92, 6, @.on
exec sp_trace_setevent @.TraceID, 92, 9, @.on
exec sp_trace_setevent @.TraceID, 92, 10, @.on
exec sp_trace_setevent @.TraceID, 92, 11, @.on
exec sp_trace_setevent @.TraceID, 92, 12, @.on
exec sp_trace_setevent @.TraceID, 92, 13, @.on
exec sp_trace_setevent @.TraceID, 92, 14, @.on
exec sp_trace_setevent @.TraceID, 92, 15, @.on
exec sp_trace_setevent @.TraceID, 92, 16, @.on
exec sp_trace_setevent @.TraceID, 92, 17, @.on
exec sp_trace_setevent @.TraceID, 92, 18, @.on
exec sp_trace_setevent @.TraceID, 94, 1, @.on
exec sp_trace_setevent @.TraceID, 94, 6, @.on
exec sp_trace_setevent @.TraceID, 94, 9, @.on
exec sp_trace_setevent @.TraceID, 94, 10, @.on
exec sp_trace_setevent @.TraceID, 94, 11, @.on
exec sp_trace_setevent @.TraceID, 94, 12, @.on
exec sp_trace_setevent @.TraceID, 94, 13, @.on
exec sp_trace_setevent @.TraceID, 94, 14, @.on
exec sp_trace_setevent @.TraceID, 94, 15, @.on
exec sp_trace_setevent @.TraceID, 94, 16, @.on
exec sp_trace_setevent @.TraceID, 94, 17, @.on
exec sp_trace_setevent @.TraceID, 94, 18, @.on
-- Set the Filters
declare @.intfilter int
declare @.bigintfilter bigint
set @.intfilter = 7
exec sp_trace_setfilter @.TraceID, 3, 1, 0, @.intfilter
exec sp_trace_setfilter @.TraceID, 10, 0, 7, N'SQL Profiler'
-- Set the trace status to start
exec sp_trace_setstatus @.TraceID, 1
-- display trace id for future references
select TraceID=@.TraceID
goto finish
error:
select ErrorCode=@.rc
finish:
GO
---
What am I doing wrong?
TIA
fcYou say that you only have an hours worth of data for the _afternoon_, when
the trace is scheduled to run between 2AM and 10 AM. How does that work? Do
you mean you only have trace data for an hour from 2 AM?
I think that the size for the tracefile you have specified might be to
small. Either specify a larger size than 50 MB, or specify 2 for the options
(2nd parameter) to have the tracefile rollover into a new file when the file
size is exceeded.
Jacco Schalkwijk
SQL Server MVP
"Scott" <quackhandle1975@.yahoo.co.uk> wrote in message
news:1128598736.359959.299190@.o13g2000cwo.googlegroups.com...
> Hi,
> I am looking to schedule a server side trace for a production server.
> I need to capture all events on the server from 2AM until 9AM. The
> server is automatically rebooted at 12-1AM so I have scripted a trace
> and wrapped it in a stored proc. A SQL Job is scheduled for 2AM to run
> the trace. When I check the trace file in the morning it doesn't show
> the correct data, it shows only an hours worth of data for the
> afternoon. The SQL Job runs with non errors.
> Here's the file:
> ---
> CREATE PROCEDURE dbo.pr_CCDTRACE
> AS
> / ****************************************
************/
> /* Created by: SQL Profiler */
> /* Date: 05/10/2005 15:48:30 */
> / ****************************************
************/
>
> -- Create a Queue
> declare @.rc int
> declare @.TraceID int
> declare @.maxfilesize bigint
> declare @.DateTime datetime
> set @.DateTime = '2005-10-06 10:00:00.000'
> set @.maxfilesize = 50
> exec @.rc = sp_trace_create @.TraceID output, 0, N'C:\CDDTrace_06102005',
> @.maxfilesize, @.Datetime
> if (@.rc != 0) goto error
> declare @.on bit
> set @.on = 1
> exec sp_trace_setevent @.TraceID, 10, 1, @.on
> exec sp_trace_setevent @.TraceID, 10, 6, @.on
> exec sp_trace_setevent @.TraceID, 10, 9, @.on
> exec sp_trace_setevent @.TraceID, 10, 10, @.on
> exec sp_trace_setevent @.TraceID, 10, 11, @.on
> exec sp_trace_setevent @.TraceID, 10, 12, @.on
> exec sp_trace_setevent @.TraceID, 10, 13, @.on
> exec sp_trace_setevent @.TraceID, 10, 14, @.on
> exec sp_trace_setevent @.TraceID, 10, 15, @.on
> exec sp_trace_setevent @.TraceID, 10, 16, @.on
> exec sp_trace_setevent @.TraceID, 10, 17, @.on
> exec sp_trace_setevent @.TraceID, 10, 18, @.on
> exec sp_trace_setevent @.TraceID, 12, 1, @.on
> exec sp_trace_setevent @.TraceID, 12, 6, @.on
> exec sp_trace_setevent @.TraceID, 12, 9, @.on
> exec sp_trace_setevent @.TraceID, 12, 10, @.on
> exec sp_trace_setevent @.TraceID, 12, 11, @.on
> exec sp_trace_setevent @.TraceID, 12, 12, @.on
> exec sp_trace_setevent @.TraceID, 12, 13, @.on
> exec sp_trace_setevent @.TraceID, 12, 14, @.on
> exec sp_trace_setevent @.TraceID, 12, 15, @.on
> exec sp_trace_setevent @.TraceID, 12, 16, @.on
> exec sp_trace_setevent @.TraceID, 12, 17, @.on
> exec sp_trace_setevent @.TraceID, 12, 18, @.on
> exec sp_trace_setevent @.TraceID, 50, 1, @.on
> exec sp_trace_setevent @.TraceID, 50, 6, @.on
> exec sp_trace_setevent @.TraceID, 50, 9, @.on
> exec sp_trace_setevent @.TraceID, 50, 10, @.on
> exec sp_trace_setevent @.TraceID, 50, 11, @.on
> exec sp_trace_setevent @.TraceID, 50, 12, @.on
> exec sp_trace_setevent @.TraceID, 50, 13, @.on
> exec sp_trace_setevent @.TraceID, 50, 14, @.on
> exec sp_trace_setevent @.TraceID, 50, 15, @.on
> exec sp_trace_setevent @.TraceID, 50, 16, @.on
> exec sp_trace_setevent @.TraceID, 50, 17, @.on
> exec sp_trace_setevent @.TraceID, 50, 18, @.on
> exec sp_trace_setevent @.TraceID, 53, 1, @.on
> exec sp_trace_setevent @.TraceID, 53, 6, @.on
> exec sp_trace_setevent @.TraceID, 53, 9, @.on
> exec sp_trace_setevent @.TraceID, 53, 10, @.on
> exec sp_trace_setevent @.TraceID, 53, 11, @.on
> exec sp_trace_setevent @.TraceID, 53, 12, @.on
> exec sp_trace_setevent @.TraceID, 53, 13, @.on
> exec sp_trace_setevent @.TraceID, 53, 14, @.on
> exec sp_trace_setevent @.TraceID, 53, 15, @.on
> exec sp_trace_setevent @.TraceID, 53, 16, @.on
> exec sp_trace_setevent @.TraceID, 53, 17, @.on
> exec sp_trace_setevent @.TraceID, 53, 18, @.on
> exec sp_trace_setevent @.TraceID, 78, 1, @.on
> exec sp_trace_setevent @.TraceID, 78, 6, @.on
> exec sp_trace_setevent @.TraceID, 78, 9, @.on
> exec sp_trace_setevent @.TraceID, 78, 10, @.on
> exec sp_trace_setevent @.TraceID, 78, 11, @.on
> exec sp_trace_setevent @.TraceID, 78, 12, @.on
> exec sp_trace_setevent @.TraceID, 78, 13, @.on
> exec sp_trace_setevent @.TraceID, 78, 14, @.on
> exec sp_trace_setevent @.TraceID, 78, 15, @.on
> exec sp_trace_setevent @.TraceID, 78, 16, @.on
> exec sp_trace_setevent @.TraceID, 78, 17, @.on
> exec sp_trace_setevent @.TraceID, 78, 18, @.on
> exec sp_trace_setevent @.TraceID, 81, 1, @.on
> exec sp_trace_setevent @.TraceID, 81, 6, @.on
> exec sp_trace_setevent @.TraceID, 81, 9, @.on
> exec sp_trace_setevent @.TraceID, 81, 10, @.on
> exec sp_trace_setevent @.TraceID, 81, 11, @.on
> exec sp_trace_setevent @.TraceID, 81, 12, @.on
> exec sp_trace_setevent @.TraceID, 81, 13, @.on
> exec sp_trace_setevent @.TraceID, 81, 14, @.on
> exec sp_trace_setevent @.TraceID, 81, 15, @.on
> exec sp_trace_setevent @.TraceID, 81, 16, @.on
> exec sp_trace_setevent @.TraceID, 81, 17, @.on
> exec sp_trace_setevent @.TraceID, 81, 18, @.on
> exec sp_trace_setevent @.TraceID, 92, 1, @.on
> exec sp_trace_setevent @.TraceID, 92, 6, @.on
> exec sp_trace_setevent @.TraceID, 92, 9, @.on
> exec sp_trace_setevent @.TraceID, 92, 10, @.on
> exec sp_trace_setevent @.TraceID, 92, 11, @.on
> exec sp_trace_setevent @.TraceID, 92, 12, @.on
> exec sp_trace_setevent @.TraceID, 92, 13, @.on
> exec sp_trace_setevent @.TraceID, 92, 14, @.on
> exec sp_trace_setevent @.TraceID, 92, 15, @.on
> exec sp_trace_setevent @.TraceID, 92, 16, @.on
> exec sp_trace_setevent @.TraceID, 92, 17, @.on
> exec sp_trace_setevent @.TraceID, 92, 18, @.on
> exec sp_trace_setevent @.TraceID, 94, 1, @.on
> exec sp_trace_setevent @.TraceID, 94, 6, @.on
> exec sp_trace_setevent @.TraceID, 94, 9, @.on
> exec sp_trace_setevent @.TraceID, 94, 10, @.on
> exec sp_trace_setevent @.TraceID, 94, 11, @.on
> exec sp_trace_setevent @.TraceID, 94, 12, @.on
> exec sp_trace_setevent @.TraceID, 94, 13, @.on
> exec sp_trace_setevent @.TraceID, 94, 14, @.on
> exec sp_trace_setevent @.TraceID, 94, 15, @.on
> exec sp_trace_setevent @.TraceID, 94, 16, @.on
> exec sp_trace_setevent @.TraceID, 94, 17, @.on
> exec sp_trace_setevent @.TraceID, 94, 18, @.on
>
> -- Set the Filters
> declare @.intfilter int
> declare @.bigintfilter bigint
> set @.intfilter = 7
> exec sp_trace_setfilter @.TraceID, 3, 1, 0, @.intfilter
> exec sp_trace_setfilter @.TraceID, 10, 0, 7, N'SQL Profiler'
>
> -- Set the trace status to start
> exec sp_trace_setstatus @.TraceID, 1
> -- display trace id for future references
> select TraceID=@.TraceID
> goto finish
> error:
> select ErrorCode=@.rc
> finish:
> GO
> ---
> What am I doing wrong?
> TIA
> fc
>sql
Monday, March 12, 2012
Scheduled DTS issue - copying of data
Hi all,
I have a problem.
I have a scheduled DTS package that runs every week that copies data
only from staging server to production into a table. When the job is
finished it states that all is successful. When I check the row count
for this table there is a discrepancy with what exists in prod to that
which exists in staging. In prod there is about 200,000 records
less. If I run the DTS job manually...then all is correct - rowcounts
are the same. When I run it from the schedule it does not.
Does anyone know why this is occurring and how to resolve the issue?
Thanks.Hi
You don't say which version of SQL Server you are running on, or if this is
a straight forward import/export or how you are handling errors.
Has data been added after the import has occurred?
John
"woohoo30@.hotmail.com" wrote:
> Hi all,
> I have a problem.
>
> I have a scheduled DTS package that runs every week that copies data
> only from staging server to production into a table. When the job is
> finished it states that all is successful. When I check the row count
> for this table there is a discrepancy with what exists in prod to that
> which exists in staging. In prod there is about 200,000 records
> less. If I run the DTS job manually...then all is correct - rowcounts
> are the same. When I run it from the schedule it does not.
> Does anyone know why this is occurring and how to resolve the issue?
> Thanks.
>|||On Nov 1, 12:20 am, John Bell <jbellnewspo...@.hotmail.com> wrote:
> Hi
> You don't say which version of SQL Server you are running on, or if this is
> a straight forward import/export or how you are handling errors.
> Has data been added after the import has occurred?
> John
>
>
Hi John,
1st it truncates the table and then it does a transform of data on
staging to production server.
there are no errors...it says successful.
It inserts about 2million rows into the table...there is a discrepancy
of 200,000.
I don't understand why it's occurring and how to fix this issue.
woohoo30|||Hi
If you use a linked server to the staging server and use a INSERT... SELECT
statement from the live server does this bring all the rows you expect?
Does the live server have a primary key? Does the staged data have this key,
if not how many rows are unique for the primary key columns?
John
"woohoo30@.hotmail.com" wrote:
> On Nov 1, 12:20 am, John Bell <jbellnewspo...@.hotmail.com> wrote:
> > Hi
> >
> > You don't say which version of SQL Server you are running on, or if this is
> > a straight forward import/export or how you are handling errors.
> >
> > Has data been added after the import has occurred?
> >
> > John
> >
> >
> >
>
> Hi John,
> 1st it truncates the table and then it does a transform of data on
> staging to production server.
> there are no errors...it says successful.
> It inserts about 2million rows into the table...there is a discrepancy
> of 200,000.
> I don't understand why it's occurring and how to fix this issue.
> woohoo30
>
I have a problem.
I have a scheduled DTS package that runs every week that copies data
only from staging server to production into a table. When the job is
finished it states that all is successful. When I check the row count
for this table there is a discrepancy with what exists in prod to that
which exists in staging. In prod there is about 200,000 records
less. If I run the DTS job manually...then all is correct - rowcounts
are the same. When I run it from the schedule it does not.
Does anyone know why this is occurring and how to resolve the issue?
Thanks.Hi
You don't say which version of SQL Server you are running on, or if this is
a straight forward import/export or how you are handling errors.
Has data been added after the import has occurred?
John
"woohoo30@.hotmail.com" wrote:
> Hi all,
> I have a problem.
>
> I have a scheduled DTS package that runs every week that copies data
> only from staging server to production into a table. When the job is
> finished it states that all is successful. When I check the row count
> for this table there is a discrepancy with what exists in prod to that
> which exists in staging. In prod there is about 200,000 records
> less. If I run the DTS job manually...then all is correct - rowcounts
> are the same. When I run it from the schedule it does not.
> Does anyone know why this is occurring and how to resolve the issue?
> Thanks.
>|||On Nov 1, 12:20 am, John Bell <jbellnewspo...@.hotmail.com> wrote:
> Hi
> You don't say which version of SQL Server you are running on, or if this is
> a straight forward import/export or how you are handling errors.
> Has data been added after the import has occurred?
> John
>
>
Hi John,
1st it truncates the table and then it does a transform of data on
staging to production server.
there are no errors...it says successful.
It inserts about 2million rows into the table...there is a discrepancy
of 200,000.
I don't understand why it's occurring and how to fix this issue.
woohoo30|||Hi
If you use a linked server to the staging server and use a INSERT... SELECT
statement from the live server does this bring all the rows you expect?
Does the live server have a primary key? Does the staged data have this key,
if not how many rows are unique for the primary key columns?
John
"woohoo30@.hotmail.com" wrote:
> On Nov 1, 12:20 am, John Bell <jbellnewspo...@.hotmail.com> wrote:
> > Hi
> >
> > You don't say which version of SQL Server you are running on, or if this is
> > a straight forward import/export or how you are handling errors.
> >
> > Has data been added after the import has occurred?
> >
> > John
> >
> >
> >
>
> Hi John,
> 1st it truncates the table and then it does a transform of data on
> staging to production server.
> there are no errors...it says successful.
> It inserts about 2million rows into the table...there is a discrepancy
> of 200,000.
> I don't understand why it's occurring and how to fix this issue.
> woohoo30
>
Subscribe to:
Posts (Atom)