Showing posts with label nightly. Show all posts
Showing posts with label nightly. Show all posts

Tuesday, March 20, 2012

Nightly Windows reboot

Is it OK to restart Windows every night when SQL Server 2000 is running on
the system? It just seems strange to me to shut the system down without
stopping SQL Server first.Hello,
It is always good to restart the Server after SQL Server shutdown. What you
could do is create a batch file to stop SQL Server and SQL Server Agent and
keep it in a
folder which can be accessible only to operations. So as operations can
execute the batch file and restart the SQL Server machine...
This will ensure that all the transction will be either rollback or roll
forwared before the server shutdown.
Thanks
Hari
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
> Is it OK to restart Windows every night when SQL Server 2000 is running on
> the system? It just seems strange to me to shut the system down without
> stopping SQL Server first.|||Operations? vas is das operations
Seriously, I'm on a government contract and they really do close at 5PM. So,
anything done overnight is automated.
Its just that I'm annoyed at the thought of anything but a controlled
shutdown.
"Hari Prasad" wrote:

> Hello,
> It is always good to restart the Server after SQL Server shutdown. What yo
u
> could do is create a batch file to stop SQL Server and SQL Server Agent an
d
> keep it in a
> folder which can be accessible only to operations. So as operations can
> execute the batch file and restart the SQL Server machine...
> This will ensure that all the transction will be either rollback or roll
> forwared before the server shutdown.
> Thanks
> Hari
> "JayKon" <JayKon@.discussions.microsoft.com> wrote in message
> news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
>
>|||> Is it OK to restart Windows every night when SQL Server 2000 is running on
> the system?
I'd ask the one who decided this why he/she wanted to do it? It certainly is
n't normal to restart
windows or SQL Server regularly.

> It just seems strange to me to shut the system down without
> stopping SQL Server first.
I suggest that whenever you *do* need to shutdown Windows, that you first st
op the SQL Server
service. At Windows shutdown, Windows will give each service a "grace period
" to stop. If the
service haven't stopped itself within that grace period, Windows will do a h
ard stop of the service.
And you probably want to avoid this. Some details and why you might not want
this you find in:
http://www.microsoft.com/technet/pr...ver/default.asp
http://www.solidqualitylearning.com/
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
> Is it OK to restart Windows every night when SQL Server 2000 is running on
> the system? It just seems strange to me to shut the system down without
> stopping SQL Server first.|||I did ask and got a vague response having to do with "system stability". I
think it is a belief going back to pre-NT 4.0, reinforced by the system hang
s
that have since been identified as a Terminal Services/single user print
driver issues and what I suspect is a small memory leak in their primary
application.
Anyway, I'm really looking for a way to do a clean shutdown of the database
before the system shuts down, rather than let the system reboot do it, or to
find out if that reall even matters.
"Tibor Karaszi" wrote:

> I'd ask the one who decided this why he/she wanted to do it? It certainly
isn't normal to restart
> windows or SQL Server regularly.
>
> I suggest that whenever you *do* need to shutdown Windows, that you first
stop the SQL Server
> service. At Windows shutdown, Windows will give each service a "grace peri
od" to stop. If the
> service haven't stopped itself within that grace period, Windows will do a
hard stop of the service.
> And you probably want to avoid this. Some details and why you might not wa
nt this you find in:
> http://www.microsoft.com/technet/pr...ver/default.asp
> http://www.solidqualitylearning.com/
>
> "JayKon" <JayKon@.discussions.microsoft.com> wrote in message
> news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
>|||>I did ask and got a vague response having to do with "system stability". I
> think it is a belief going back to pre-NT 4.0
Yes, some tend to ignore how much the Windows platform has evolved over the
past 1.5 decade.

> reinforced by the system hangs
> that have since been identified as a Terminal Services/single user print
> driver issues and what I suspect is a small memory leak in their primary
> application.
So did they/you fix the issue? Perhaps this was and old, and now fixed, issu
e and the reboot routine
can be removed?

> Anyway, I'm really looking for a way to do a clean shutdown of the databas
e
> before the system shuts down, rather than let the system reboot do it, or
to
> find out if that reall even matters.
Did you read the article I posted a link to? That answers your "if that real
ly matters" question.
And if you want to let the service to have the time to shut down normally, j
ust schedule a normal
NET STOP command before the re-boot (and give it plenty of time to stop...).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:826C7980-53AE-4791-B469-63B6196202B7@.microsoft.com...[vbcol=seagreen]
>I did ask and got a vague response having to do with "system stability". I
> think it is a belief going back to pre-NT 4.0, reinforced by the system ha
ngs
> that have since been identified as a Terminal Services/single user print
> driver issues and what I suspect is a small memory leak in their primary
> application.
> Anyway, I'm really looking for a way to do a clean shutdown of the databas
e
> before the system shuts down, rather than let the system reboot do it, or
to
> find out if that reall even matters.
> "Tibor Karaszi" wrote:
>|||> >I did ask and got a vague response having to do with "system stability". I">
> Yes, some tend to ignore how much the Windows platform has evolved over the past 1
.5 decade.
Agreed.

>
>
> So did they/you fix the issue? Perhaps this was and old, and now fixed, is
sue and the reboot routine
> can be removed?
The printer issue is current and took me a week to ID. Someone is working on
it. The memory leak is suspected, but not confirmed.
Until I know much more, I have no intention of removing it.

>
> Did you read the article I posted a link to? That answers your "if that really mat
ters" question.
I think we made our posts about the same time, I have scanned it now. It
basically says the server needs a little time to shutdown cleanly - always a
good idea.
[vbcol=seagreen]
> And if you want to let the service to have the time to shut down normally,
just schedule a normal
> NET STOP command before the re-boot (and give it plenty of time to stop...).[/vbco
l]
I think this is what I want. Can I put it directly into Scheduled Events
15-30 minutes before the reboot?|||> I think this is what I want. Can I put it directly into Scheduled Events
> 15-30 minutes before the reboot?
Yes, that seems reasonable. Or, depending on how you do the reboot, you migh
t be able to add the NET
STOP in the same job/event as the reboot (assuming you do the reboot from so
me bat file).
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:534C179A-E188-4867-8B14-74156E95C960@.microsoft.com...
> Agreed.
>
> The printer issue is current and took me a week to ID. Someone is working
on
> it. The memory leak is suspected, but not confirmed.
> Until I know much more, I have no intention of removing it.
>
> I think we made our posts about the same time, I have scanned it now. It
> basically says the server needs a little time to shutdown cleanly - always
a
> good idea.
>
> I think this is what I want. Can I put it directly into Scheduled Events
> 15-30 minutes before the reboot?
>|||Since I'm dealing with a vendor that is doing the admin, I've sent them a
question about adding it to the at file.
The "funny" part, is the manager is so comfortable doing this restart just
the way it is and I always have trouble explaining that when you set things
up properly, you just don't get issues.
His argument is an old one: is it really worth the time to fix it properly,
when rebooting will keep us running? My answer (which goes unspoken a lot) i
s
that it never should have been done that way in the first place.
Anyway, thanks.
"Tibor Karaszi" wrote:

> Yes, that seems reasonable. Or, depending on how you do the reboot, you mi
ght be able to add the NET
> STOP in the same job/event as the reboot (assuming you do the reboot from
some bat file).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "JayKon" <JayKon@.discussions.microsoft.com> wrote in message
> news:534C179A-E188-4867-8B14-74156E95C960@.microsoft.com...
>

Monday, March 19, 2012

Nightly Windows reboot

Is it OK to restart Windows every night when SQL Server 2000 is running on
the system? It just seems strange to me to shut the system down without
stopping SQL Server first.
Hello,
It is always good to restart the Server after SQL Server shutdown. What you
could do is create a batch file to stop SQL Server and SQL Server Agent and
keep it in a
folder which can be accessible only to operations. So as operations can
execute the batch file and restart the SQL Server machine...
This will ensure that all the transction will be either rollback or roll
forwared before the server shutdown.
Thanks
Hari
"JayKon" <JayKon@.discussions.microsoft.com> wrote in message
news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
> Is it OK to restart Windows every night when SQL Server 2000 is running on
> the system? It just seems strange to me to shut the system down without
> stopping SQL Server first.
|||Operations? vas is das operations
Seriously, I'm on a government contract and they really do close at 5PM. So,
anything done overnight is automated.
Its just that I'm annoyed at the thought of anything but a controlled
shutdown.
"Hari Prasad" wrote:

> Hello,
> It is always good to restart the Server after SQL Server shutdown. What you
> could do is create a batch file to stop SQL Server and SQL Server Agent and
> keep it in a
> folder which can be accessible only to operations. So as operations can
> execute the batch file and restart the SQL Server machine...
> This will ensure that all the transction will be either rollback or roll
> forwared before the server shutdown.
> Thanks
> Hari
> "JayKon" <JayKon@.discussions.microsoft.com> wrote in message
> news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
>
>
|||I did ask and got a vague response having to do with "system stability". I
think it is a belief going back to pre-NT 4.0, reinforced by the system hangs
that have since been identified as a Terminal Services/single user print
driver issues and what I suspect is a small memory leak in their primary
application.
Anyway, I'm really looking for a way to do a clean shutdown of the database
before the system shuts down, rather than let the system reboot do it, or to
find out if that reall even matters.
"Tibor Karaszi" wrote:

> I'd ask the one who decided this why he/she wanted to do it? It certainly isn't normal to restart
> windows or SQL Server regularly.
>
> I suggest that whenever you *do* need to shutdown Windows, that you first stop the SQL Server
> service. At Windows shutdown, Windows will give each service a "grace period" to stop. If the
> service haven't stopped itself within that grace period, Windows will do a hard stop of the service.
> And you probably want to avoid this. Some details and why you might not want this you find in:
> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/sqlIObasics.mspx
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "JayKon" <JayKon@.discussions.microsoft.com> wrote in message
> news:C1A3F257-EB2B-46FC-B117-2C4C406D20A5@.microsoft.com...
>
|||> >I did ask and got a vague response having to do with "system stability". I
> Yes, some tend to ignore how much the Windows platform has evolved over the past 1.5 decade.
Agreed.

>
>
> So did they/you fix the issue? Perhaps this was and old, and now fixed, issue and the reboot routine
> can be removed?
The printer issue is current and took me a week to ID. Someone is working on
it. The memory leak is suspected, but not confirmed.
Until I know much more, I have no intention of removing it.

>
> Did you read the article I posted a link to? That answers your "if that really matters" question.
I think we made our posts about the same time, I have scanned it now. It
basically says the server needs a little time to shutdown cleanly - always a
good idea.

> And if you want to let the service to have the time to shut down normally, just schedule a normal
> NET STOP command before the re-boot (and give it plenty of time to stop...).
I think this is what I want. Can I put it directly into Scheduled Events
15-30 minutes before the reboot?
|||Since I'm dealing with a vendor that is doing the admin, I've sent them a
question about adding it to the at file.
The "funny" part, is the manager is so comfortable doing this restart just
the way it is and I always have trouble explaining that when you set things
up properly, you just don't get issues.
His argument is an old one: is it really worth the time to fix it properly,
when rebooting will keep us running? My answer (which goes unspoken a lot) is
that it never should have been done that way in the first place.
Anyway, thanks.
"Tibor Karaszi" wrote:

> Yes, that seems reasonable. Or, depending on how you do the reboot, you might be able to add the NET
> STOP in the same job/event as the reboot (assuming you do the reboot from some bat file).
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "JayKon" <JayKon@.discussions.microsoft.com> wrote in message
> news:534C179A-E188-4867-8B14-74156E95C960@.microsoft.com...
>

Nightly Update / Fallback protection

I have become involved with an assessment of a client's nightly update
procedures, and I keep running into the following practice.
The client consistently copies databases off to separate locations and
performs updates upon the new copy. After successful update, the
updated database is then copied back to the origin location and
becomes the new version. All of this, obviously, to protect
themselves in case of error. I can't help but suspect that SQL Server
provides an easier way to do it.
In the mainframe universe, this used to be accomplished via
generational datasets which would be promoted as the baseline when the
update completes. I guess what I'm asking is if SQL Server provides
any kind of "checkpoint-fallback" capability that the client could use
instead of this monstrous time-consuming practice. When talking
thousands of updates in a batch, I'm not sure transactioning would be
the best way to do it. That would be one big honking rollback.
Thanks in advance to any of you architects out there!
SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a "database snapshot"
(CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Copy database are initially
empty and consume close to 0 disk space, i.e., the snapshot takes only a few seconds to take. Then
modify your Orig database. As you modify Orig database, the pages to be modified are first copied to
the Copy databases' database files. This way, the copy database always has the data as it was when
the snapshot was produced. If you need to "fall-back", then you can RESTORE DATABASE Orig FROM
DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database files) are copied back to
the Orig database' files and you are back where you began. Concept is called "Copy on write".
Same-same (concept) but different (implementation). :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177351816.251254.221810@.b58g2000hsg.googlegr oups.com...
>I have become involved with an assessment of a client's nightly update
> procedures, and I keep running into the following practice.
> The client consistently copies databases off to separate locations and
> performs updates upon the new copy. After successful update, the
> updated database is then copied back to the origin location and
> becomes the new version. All of this, obviously, to protect
> themselves in case of error. I can't help but suspect that SQL Server
> provides an easier way to do it.
> In the mainframe universe, this used to be accomplished via
> generational datasets which would be promoted as the baseline when the
> update completes. I guess what I'm asking is if SQL Server provides
> any kind of "checkpoint-fallback" capability that the client could use
> instead of this monstrous time-consuming practice. When talking
> thousands of updates in a batch, I'm not sure transactioning would be
> the best way to do it. That would be one big honking rollback.
> Thanks in advance to any of you architects out there!
>
|||It is called a backup before you do any changes. Then if there is an issue
you simply restore.
Andrew J. Kelly SQL MVP
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177351816.251254.221810@.b58g2000hsg.googlegr oups.com...
>I have become involved with an assessment of a client's nightly update
> procedures, and I keep running into the following practice.
> The client consistently copies databases off to separate locations and
> performs updates upon the new copy. After successful update, the
> updated database is then copied back to the origin location and
> becomes the new version. All of this, obviously, to protect
> themselves in case of error. I can't help but suspect that SQL Server
> provides an easier way to do it.
> In the mainframe universe, this used to be accomplished via
> generational datasets which would be promoted as the baseline when the
> update completes. I guess what I'm asking is if SQL Server provides
> any kind of "checkpoint-fallback" capability that the client could use
> instead of this monstrous time-consuming practice. When talking
> thousands of updates in a batch, I'm not sure transactioning would be
> the best way to do it. That would be one big honking rollback.
> Thanks in advance to any of you architects out there!
>
|||On Apr 23, 1:23 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a "database snapshot"
> (CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Copy database are initially
> empty and consume close to 0 disk space, i.e., the snapshot takes only a few seconds to take. Then
> modify your Orig database. As you modify Orig database, the pages to be modified are first copied to
> the Copy databases' database files. This way, the copy database always has the data as it was when
> the snapshot was produced. If you need to "fall-back", then you can RESTORE DATABASE Orig FROM
> DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database files) are copied back to
> the Orig database' files and you are back where you began. Concept is called "Copy on write".
> Same-same (concept) but different (implementation). :-)
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "BizEd" <EdMathia...@.gmail.com> wrote in message
> news:1177351816.251254.221810@.b58g2000hsg.googlegr oups.com...
>
>
>
> - Show quoted text -
Tibor,
Thanks. That's the type of functionality I was looking for. A simple
backup is not a sufficient solution when you are talking about a
multiple stage update process. If you wish to restart a step in the
process, the backup would necessitate going all the way back to the
beginning. Your solution is in essence "a delta file" which provides
functionality much more in line with the concept of mainframe
generational data sets!
Now to get the client on to SQL 2005....harrumph!
|||Note that you can have several "delta-files" (several database snapshots). But if you want to
restore from any of them, you need for first DROP DATABASE for all those snapshots except the one to
restore from.
Another important thing is that when you restore from a database snapshot, you break the log backup
chain sequence for your database. So, if you are doing log backups for that database, you want to do
a BACKUP DATABASE after restoring from a database snapshot.
And, as always, make sure you read all about this in Books Online first. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177365104.403457.180780@.b58g2000hsg.googlegr oups.com...
> On Apr 23, 1:23 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> Tibor,
> Thanks. That's the type of functionality I was looking for. A simple
> backup is not a sufficient solution when you are talking about a
> multiple stage update process. If you wish to restart a step in the
> process, the backup would necessitate going all the way back to the
> beginning. Your solution is in essence "a delta file" which provides
> functionality much more in line with the concept of mainframe
> generational data sets!
> Now to get the client on to SQL 2005....harrumph!
>
|||As a standard process, this seems excessive.
You are aware that within the processing, SQLServer (like most major
databases) allows you to define a transaction that holds off
commitment until all the steps have completed successfully, and can be
rolled back if any errors are detected?
Josh
On 23 Apr 2007 11:10:16 -0700, BizEd <EdMathias18@.gmail.com> wrote:

>I have become involved with an assessment of a client's nightly update
>procedures, and I keep running into the following practice.
>The client consistently copies databases off to separate locations and
>performs updates upon the new copy. After successful update, the
>updated database is then copied back to the origin location and
>becomes the new version. All of this, obviously, to protect
>themselves in case of error. I can't help but suspect that SQL Server
>provides an easier way to do it.
>In the mainframe universe, this used to be accomplished via
>generational datasets which would be promoted as the baseline when the
>update completes. I guess what I'm asking is if SQL Server provides
>any kind of "checkpoint-fallback" capability that the client could use
>instead of this monstrous time-consuming practice. When talking
>thousands of updates in a batch, I'm not sure transactioning would be
>the best way to do it. That would be one big honking rollback.
>Thanks in advance to any of you architects out there!

Nightly Update / Fallback protection

I have become involved with an assessment of a client's nightly update
procedures, and I keep running into the following practice.
The client consistently copies databases off to separate locations and
performs updates upon the new copy. After successful update, the
updated database is then copied back to the origin location and
becomes the new version. All of this, obviously, to protect
themselves in case of error. I can't help but suspect that SQL Server
provides an easier way to do it.
In the mainframe universe, this used to be accomplished via
generational datasets which would be promoted as the baseline when the
update completes. I guess what I'm asking is if SQL Server provides
any kind of "checkpoint-fallback" capability that the client could use
instead of this monstrous time-consuming practice. When talking
thousands of updates in a batch, I'm not sure transactioning would be
the best way to do it. That would be one big honking rollback.
Thanks in advance to any of you architects out there!SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a "d
atabase snapshot"
(CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Copy
database are initially
empty and consume close to 0 disk space, i.e., the snapshot takes only a few
seconds to take. Then
modify your Orig database. As you modify Orig database, the pages to be modi
fied are first copied to
the Copy databases' database files. This way, the copy database always has t
he data as it was when
the snapshot was produced. If you need to "fall-back", then you can RESTORE
DATABASE Orig FROM
DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database fil
es) are copied back to
the Orig database' files and you are back where you began. Concept is called
"Copy on write".
Same-same (concept) but different (implementation). :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>I have become involved with an assessment of a client's nightly update
> procedures, and I keep running into the following practice.
> The client consistently copies databases off to separate locations and
> performs updates upon the new copy. After successful update, the
> updated database is then copied back to the origin location and
> becomes the new version. All of this, obviously, to protect
> themselves in case of error. I can't help but suspect that SQL Server
> provides an easier way to do it.
> In the mainframe universe, this used to be accomplished via
> generational datasets which would be promoted as the baseline when the
> update completes. I guess what I'm asking is if SQL Server provides
> any kind of "checkpoint-fallback" capability that the client could use
> instead of this monstrous time-consuming practice. When talking
> thousands of updates in a batch, I'm not sure transactioning would be
> the best way to do it. That would be one big honking rollback.
> Thanks in advance to any of you architects out there!
>|||It is called a backup before you do any changes. Then if there is an issue
you simply restore.
Andrew J. Kelly SQL MVP
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>I have become involved with an assessment of a client's nightly update
> procedures, and I keep running into the following practice.
> The client consistently copies databases off to separate locations and
> performs updates upon the new copy. After successful update, the
> updated database is then copied back to the origin location and
> becomes the new version. All of this, obviously, to protect
> themselves in case of error. I can't help but suspect that SQL Server
> provides an easier way to do it.
> In the mainframe universe, this used to be accomplished via
> generational datasets which would be promoted as the baseline when the
> update completes. I guess what I'm asking is if SQL Server provides
> any kind of "checkpoint-fallback" capability that the client could use
> instead of this monstrous time-consuming practice. When talking
> thousands of updates in a batch, I'm not sure transactioning would be
> the best way to do it. That would be one big honking rollback.
> Thanks in advance to any of you architects out there!
>|||On Apr 23, 1:23 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a
"database snapshot"
> (CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Cop
y database are initially
> empty and consume close to 0 disk space, i.e., the snapshot takes only a f
ew seconds to take. Then
> modify your Orig database. As you modify Orig database, the pages to be mo
dified are first copied to
> the Copy databases' database files. This way, the copy database always has
the data as it was when
> the snapshot was produced. If you need to "fall-back", then you can RESTOR
E DATABASE Orig FROM
> DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database f
iles) are copied back to
> the Orig database' files and you are back where you began. Concept is call
ed "Copy on write".
> Same-same (concept) but different (implementation). :-)
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asph
ttp://sqlblog.com/blogs/tibor_karaszi
> "BizEd" <EdMathia...@.gmail.com> wrote in message
> news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>
>
>
>
>
> - Show quoted text -
Tibor,
Thanks. That's the type of functionality I was looking for. A simple
backup is not a sufficient solution when you are talking about a
multiple stage update process. If you wish to restart a step in the
process, the backup would necessitate going all the way back to the
beginning. Your solution is in essence "a delta file" which provides
functionality much more in line with the concept of mainframe
generational data sets!
Now to get the client on to SQL 2005....harrumph!|||Note that you can have several "delta-files" (several database snapshots). B
ut if you want to
restore from any of them, you need for first DROP DATABASE for all those sna
pshots except the one to
restore from.
Another important thing is that when you restore from a database snapshot, y
ou break the log backup
chain sequence for your database. So, if you are doing log backups for that
database, you want to do
a BACKUP DATABASE after restoring from a database snapshot.
And, as always, make sure you read all about this in Books Online first. :-)
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177365104.403457.180780@.b58g2000hsg.googlegroups.com...
> On Apr 23, 1:23 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> Tibor,
> Thanks. That's the type of functionality I was looking for. A simple
> backup is not a sufficient solution when you are talking about a
> multiple stage update process. If you wish to restart a step in the
> process, the backup would necessitate going all the way back to the
> beginning. Your solution is in essence "a delta file" which provides
> functionality much more in line with the concept of mainframe
> generational data sets!
> Now to get the client on to SQL 2005....harrumph!
>|||As a standard process, this seems excessive.
You are aware that within the processing, SQLServer (like most major
databases) allows you to define a transaction that holds off
commitment until all the steps have completed successfully, and can be
rolled back if any errors are detected?
Josh
On 23 Apr 2007 11:10:16 -0700, BizEd <EdMathias18@.gmail.com> wrote:

>I have become involved with an assessment of a client's nightly update
>procedures, and I keep running into the following practice.
>The client consistently copies databases off to separate locations and
>performs updates upon the new copy. After successful update, the
>updated database is then copied back to the origin location and
>becomes the new version. All of this, obviously, to protect
>themselves in case of error. I can't help but suspect that SQL Server
>provides an easier way to do it.
>In the mainframe universe, this used to be accomplished via
>generational datasets which would be promoted as the baseline when the
>update completes. I guess what I'm asking is if SQL Server provides
>any kind of "checkpoint-fallback" capability that the client could use
>instead of this monstrous time-consuming practice. When talking
>thousands of updates in a batch, I'm not sure transactioning would be
>the best way to do it. That would be one big honking rollback.
>Thanks in advance to any of you architects out there!

Nightly Update / Fallback protection

I have become involved with an assessment of a client's nightly update
procedures, and I keep running into the following practice.
The client consistently copies databases off to separate locations and
performs updates upon the new copy. After successful update, the
updated database is then copied back to the origin location and
becomes the new version. All of this, obviously, to protect
themselves in case of error. I can't help but suspect that SQL Server
provides an easier way to do it.
In the mainframe universe, this used to be accomplished via
generational datasets which would be promoted as the baseline when the
update completes. I guess what I'm asking is if SQL Server provides
any kind of "checkpoint-fallback" capability that the client could use
instead of this monstrous time-consuming practice. When talking
thousands of updates in a batch, I'm not sure transactioning would be
the best way to do it. That would be one big honking rollback.
Thanks in advance to any of you architects out there!SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a "database snapshot"
(CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Copy database are initially
empty and consume close to 0 disk space, i.e., the snapshot takes only a few seconds to take. Then
modify your Orig database. As you modify Orig database, the pages to be modified are first copied to
the Copy databases' database files. This way, the copy database always has the data as it was when
the snapshot was produced. If you need to "fall-back", then you can RESTORE DATABASE Orig FROM
DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database files) are copied back to
the Orig database' files and you are back where you began. Concept is called "Copy on write".
Same-same (concept) but different (implementation). :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>I have become involved with an assessment of a client's nightly update
> procedures, and I keep running into the following practice.
> The client consistently copies databases off to separate locations and
> performs updates upon the new copy. After successful update, the
> updated database is then copied back to the origin location and
> becomes the new version. All of this, obviously, to protect
> themselves in case of error. I can't help but suspect that SQL Server
> provides an easier way to do it.
> In the mainframe universe, this used to be accomplished via
> generational datasets which would be promoted as the baseline when the
> update completes. I guess what I'm asking is if SQL Server provides
> any kind of "checkpoint-fallback" capability that the client could use
> instead of this monstrous time-consuming practice. When talking
> thousands of updates in a batch, I'm not sure transactioning would be
> the best way to do it. That would be one big honking rollback.
> Thanks in advance to any of you architects out there!
>|||It is called a backup before you do any changes. Then if there is an issue
you simply restore.
--
Andrew J. Kelly SQL MVP
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>I have become involved with an assessment of a client's nightly update
> procedures, and I keep running into the following practice.
> The client consistently copies databases off to separate locations and
> performs updates upon the new copy. After successful update, the
> updated database is then copied back to the origin location and
> becomes the new version. All of this, obviously, to protect
> themselves in case of error. I can't help but suspect that SQL Server
> provides an easier way to do it.
> In the mainframe universe, this used to be accomplished via
> generational datasets which would be promoted as the baseline when the
> update completes. I guess what I'm asking is if SQL Server provides
> any kind of "checkpoint-fallback" capability that the client could use
> instead of this monstrous time-consuming practice. When talking
> thousands of updates in a batch, I'm not sure transactioning would be
> the best way to do it. That would be one big honking rollback.
> Thanks in advance to any of you architects out there!
>|||On Apr 23, 1:23 pm, "Tibor Karaszi"
<tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
> SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a "database snapshot"
> (CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Copy database are initially
> empty and consume close to 0 disk space, i.e., the snapshot takes only a few seconds to take. Then
> modify your Orig database. As you modify Orig database, the pages to be modified are first copied to
> the Copy databases' database files. This way, the copy database always has the data as it was when
> the snapshot was produced. If you need to "fall-back", then you can RESTORE DATABASE Orig FROM
> DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database files) are copied back to
> the Orig database' files and you are back where you began. Concept is called "Copy on write".
> Same-same (concept) but different (implementation). :-)
> --
> Tibor Karaszi, SQL Server MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
> "BizEd" <EdMathia...@.gmail.com> wrote in message
> news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>
> >I have become involved with an assessment of a client's nightly update
> > procedures, and I keep running into the following practice.
> > The client consistently copies databases off to separate locations and
> > performs updates upon the new copy. After successful update, the
> > updated database is then copied back to the origin location and
> > becomes the new version. All of this, obviously, to protect
> > themselves in case of error. I can't help but suspect that SQL Server
> > provides an easier way to do it.
> > In the mainframe universe, this used to be accomplished via
> > generational datasets which would be promoted as the baseline when the
> > update completes. I guess what I'm asking is if SQL Server provides
> > any kind of "checkpoint-fallback" capability that the client could use
> > instead of this monstrous time-consuming practice. When talking
> > thousands of updates in a batch, I'm not sure transactioning would be
> > the best way to do it. That would be one big honking rollback.
> > Thanks in advance to any of you architects out there!- Hide quoted text -
> - Show quoted text -
Tibor,
Thanks. That's the type of functionality I was looking for. A simple
backup is not a sufficient solution when you are talking about a
multiple stage update process. If you wish to restart a step in the
process, the backup would necessitate going all the way back to the
beginning. Your solution is in essence "a delta file" which provides
functionality much more in line with the concept of mainframe
generational data sets!
Now to get the client on to SQL 2005....harrumph!|||Note that you can have several "delta-files" (several database snapshots). But if you want to
restore from any of them, you need for first DROP DATABASE for all those snapshots except the one to
restore from.
Another important thing is that when you restore from a database snapshot, you break the log backup
chain sequence for your database. So, if you are doing log backups for that database, you want to do
a BACKUP DATABASE after restoring from a database snapshot.
And, as always, make sure you read all about this in Books Online first. :-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"BizEd" <EdMathias18@.gmail.com> wrote in message
news:1177365104.403457.180780@.b58g2000hsg.googlegroups.com...
> On Apr 23, 1:23 pm, "Tibor Karaszi"
> <tibor_please.no.email_kara...@.hotmail.nomail.com> wrote:
>> SQL Server 2005 (Enterprise Edition) has, sort of, this. You can create a "database snapshot"
>> (CREATE DATABASE Copy AS SNAPSHOT OF Orig). The database files for the Copy database are
>> initially
>> empty and consume close to 0 disk space, i.e., the snapshot takes only a few seconds to take.
>> Then
>> modify your Orig database. As you modify Orig database, the pages to be modified are first copied
>> to
>> the Copy databases' database files. This way, the copy database always has the data as it was
>> when
>> the snapshot was produced. If you need to "fall-back", then you can RESTORE DATABASE Orig FROM
>> DATABASE_SNAPSHOT 'Copy', and all pages (in the Copy databases' database files) are copied back
>> to
>> the Orig database' files and you are back where you began. Concept is called "Copy on write".
>> Same-same (concept) but different (implementation). :-)
>> --
>> Tibor Karaszi, SQL Server
>> MVPhttp://www.karaszi.com/sqlserver/default.asphttp://sqlblog.com/blogs/tibor_karaszi
>> "BizEd" <EdMathia...@.gmail.com> wrote in message
>> news:1177351816.251254.221810@.b58g2000hsg.googlegroups.com...
>>
>> >I have become involved with an assessment of a client's nightly update
>> > procedures, and I keep running into the following practice.
>> > The client consistently copies databases off to separate locations and
>> > performs updates upon the new copy. After successful update, the
>> > updated database is then copied back to the origin location and
>> > becomes the new version. All of this, obviously, to protect
>> > themselves in case of error. I can't help but suspect that SQL Server
>> > provides an easier way to do it.
>> > In the mainframe universe, this used to be accomplished via
>> > generational datasets which would be promoted as the baseline when the
>> > update completes. I guess what I'm asking is if SQL Server provides
>> > any kind of "checkpoint-fallback" capability that the client could use
>> > instead of this monstrous time-consuming practice. When talking
>> > thousands of updates in a batch, I'm not sure transactioning would be
>> > the best way to do it. That would be one big honking rollback.
>> > Thanks in advance to any of you architects out there!- Hide quoted text -
>> - Show quoted text -
> Tibor,
> Thanks. That's the type of functionality I was looking for. A simple
> backup is not a sufficient solution when you are talking about a
> multiple stage update process. If you wish to restart a step in the
> process, the backup would necessitate going all the way back to the
> beginning. Your solution is in essence "a delta file" which provides
> functionality much more in line with the concept of mainframe
> generational data sets!
> Now to get the client on to SQL 2005....harrumph!
>|||As a standard process, this seems excessive.
You are aware that within the processing, SQLServer (like most major
databases) allows you to define a transaction that holds off
commitment until all the steps have completed successfully, and can be
rolled back if any errors are detected?
Josh
On 23 Apr 2007 11:10:16 -0700, BizEd <EdMathias18@.gmail.com> wrote:
>I have become involved with an assessment of a client's nightly update
>procedures, and I keep running into the following practice.
>The client consistently copies databases off to separate locations and
>performs updates upon the new copy. After successful update, the
>updated database is then copied back to the origin location and
>becomes the new version. All of this, obviously, to protect
>themselves in case of error. I can't help but suspect that SQL Server
>provides an easier way to do it.
>In the mainframe universe, this used to be accomplished via
>generational datasets which would be promoted as the baseline when the
>update completes. I guess what I'm asking is if SQL Server provides
>any kind of "checkpoint-fallback" capability that the client could use
>instead of this monstrous time-consuming practice. When talking
>thousands of updates in a batch, I'm not sure transactioning would be
>the best way to do it. That would be one big honking rollback.
>Thanks in advance to any of you architects out there!

Nightly Refresh

Please help.
I have Database A (Archived data), Database B (Transactional data).
Both A and B do not have any timestamps in any tables.
I need to bring A (only once because it is archived data) and B with
only differentials into Database C for reporting purposes.

Currently C is cleared before loading B with differentials every night
and A is not loaded since it takes 15 hours to load.

Now I want to bring A once and leave it and then bring B every night
with differentials without clearing C.

Please suggest some solutions.

Thank You(rohini.srigiriraju@.gmail.com) writes:

Quote:

Originally Posted by

I have Database A (Archived data), Database B (Transactional data).
Both A and B do not have any timestamps in any tables.
I need to bring A (only once because it is archived data) and B with
only differentials into Database C for reporting purposes.
>
Currently C is cleared before loading B with differentials every night
and A is not loaded since it takes 15 hours to load.
>
Now I want to bring A once and leave it and then bring B every night
with differentials without clearing C.
>
Please suggest some solutions.


It's very difficult to suggest solutions from this high-level description.
And it's not exactly clear what you mean with differentials. I would
guess new and changed rows since last load. Do you also need to deal
with deletions?

Maybe you could examplify with some tables to give us some more meat?

Please also specify which version of SQL Server you are using.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

Nightly refresh

Please help. Taking over somebody's half done job. Here is my
situation:
I have Database A (with Transactional data), Database B(Archived
data). I need to bring both Database A and Database B Into Database C
after cleaning for reporting purposes.
Database B should be brought into Database C once it is archived data
and Database A should be brought into Database C with differentials
only.
Also Database A and Database B do not have any timestamps in any
tables.
Currently Database C is cleared every night to load Database A.
Database B is not loaded since it takes 15 hours to complete the job.
I can successfully bring Database A into Database C with
differentials. Now I would want to add Database B into Database C and
keep it as is and would want to load only the differentials into C
from A without clearing C.
Please suggest some workarounds.
Thank YouDoes it take 15 hours to load database C with the data from database A? or
15 hours to load database B into database C?
What size of databases are we talking about here?
You also said you can already bring A into C with differentials but then in
the next sentence you said you want to load only the differentials into C
from A without clearing C.
If you could clarify some of those it would make it easier...
--
Geoff Chovaz
MCTS: SQL Server 2005
MCITP: Database Administrator
MCITP: Database Developer
<rohini.srigiriraju@.gmail.com> wrote in message
news:1190211476.759596.123330@.50g2000hsm.googlegroups.com...
> Please help. Taking over somebody's half done job. Here is my
> situation:
> I have Database A (with Transactional data), Database B(Archived
> data). I need to bring both Database A and Database B Into Database C
> after cleaning for reporting purposes.
> Database B should be brought into Database C once it is archived data
> and Database A should be brought into Database C with differentials
> only.
> Also Database A and Database B do not have any timestamps in any
> tables.
> Currently Database C is cleared every night to load Database A.
> Database B is not loaded since it takes 15 hours to complete the job.
> I can successfully bring Database A into Database C with
> differentials. Now I would want to add Database B into Database C and
> keep it as is and would want to load only the differentials into C
> from A without clearing C.
> Please suggest some workarounds.
> Thank You
>|||Restore DB B to DB D.
Differential load DB C into DB D.
Differential load DB A into DB D.
Rename DB C to DB E (in case you need it later)
Rename DB D to DB C.
Set up regular differential load DB A to (the new) DB C.
Drop DB E.
hth
Quentin
<rohini.srigiriraju@.gmail.com> wrote in message
news:1190211476.759596.123330@.50g2000hsm.googlegroups.com...
> Please help. Taking over somebody's half done job. Here is my
> situation:
> I have Database A (with Transactional data), Database B(Archived
> data). I need to bring both Database A and Database B Into Database C
> after cleaning for reporting purposes.
> Database B should be brought into Database C once it is archived data
> and Database A should be brought into Database C with differentials
> only.
> Also Database A and Database B do not have any timestamps in any
> tables.
> Currently Database C is cleared every night to load Database A.
> Database B is not loaded since it takes 15 hours to complete the job.
> I can successfully bring Database A into Database C with
> differentials. Now I would want to add Database B into Database C and
> keep it as is and would want to load only the differentials into C
> from A without clearing C.
> Please suggest some workarounds.
> Thank You
>

nightly rebooting of server

SQL 2000 patched up running under SBS2003
we shutdown and reboot automatically at 2AM into DOS and backup entire
server via Ghost onto a backup and drive and restart server
Question: are there any issues with rebooting SQL daily?
a another consultant claims there are but I can find no mentions in MS db or
literature.
craig@.computermagic.net(donotspam)Hi
If you cleanly shut down SQL server there should be no issue
http://msdn.microsoft.com/library/d...>
rt_6628.asp,
but anything connected to the server would need to handle this loss.
John
"computermagic" <craig@.computermagic.net(donotspam)> wrote in message
news:716D85E1-E2E7-4EFA-9201-0CFF53556126@.microsoft.com...
> SQL 2000 patched up running under SBS2003
> we shutdown and reboot automatically at 2AM into DOS and backup entire
> server via Ghost onto a backup and drive and restart server
> Question: are there any issues with rebooting SQL daily?
> a another consultant claims there are but I can find no mentions in MS db
> or
> literature.
> craig@.computermagic.net(donotspam)|||The only issue is that you are blowing away your data cache and query cache,
so this is why queries in the morning run a lot more slowly than they do in
the afternoon.
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"computermagic" <craig@.computermagic.net(donotspam)> wrote in message
news:716D85E1-E2E7-4EFA-9201-0CFF53556126@.microsoft.com...
> SQL 2000 patched up running under SBS2003
> we shutdown and reboot automatically at 2AM into DOS and backup entire
> server via Ghost onto a backup and drive and restart server
> Question: are there any issues with rebooting SQL daily?
> a another consultant claims there are but I can find no mentions in MS db
> or
> literature.
> craig@.computermagic.net(donotspam)

nightly rebooting of server

SQL 2000 patched up running under SBS2003
we shutdown and reboot automatically at 2AM into DOS and backup entire
server via Ghost onto a backup and drive and restart server
Question: are there any issues with rebooting SQL daily?
a another consultant claims there are but I can find no mentions in MS db or
literature.
craig@.computermagic.net(donotspam)Hi
If you cleanly shut down SQL server there should be no issue
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/adminsql/ad_1_start_6628.asp,
but anything connected to the server would need to handle this loss.
John
"computermagic" <craig@.computermagic.net(donotspam)> wrote in message
news:716D85E1-E2E7-4EFA-9201-0CFF53556126@.microsoft.com...
> SQL 2000 patched up running under SBS2003
> we shutdown and reboot automatically at 2AM into DOS and backup entire
> server via Ghost onto a backup and drive and restart server
> Question: are there any issues with rebooting SQL daily?
> a another consultant claims there are but I can find no mentions in MS db
> or
> literature.
> craig@.computermagic.net(donotspam)|||The only issue is that you are blowing away your data cache and query cache,
so this is why queries in the morning run a lot more slowly than they do in
the afternoon.
--
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"computermagic" <craig@.computermagic.net(donotspam)> wrote in message
news:716D85E1-E2E7-4EFA-9201-0CFF53556126@.microsoft.com...
> SQL 2000 patched up running under SBS2003
> we shutdown and reboot automatically at 2AM into DOS and backup entire
> server via Ghost onto a backup and drive and restart server
> Question: are there any issues with rebooting SQL daily?
> a another consultant claims there are but I can find no mentions in MS db
> or
> literature.
> craig@.computermagic.net(donotspam)

nightly rebooting of server

SQL 2000 patched up running under SBS2003
we shutdown and reboot automatically at 2AM into DOS and backup entire
server via Ghost onto a backup and drive and restart server
Question: are there any issues with rebooting SQL daily?
a another consultant claims there are but I can find no mentions in MS db or
literature.
craig@.computermagic.net(donotspam)
Hi
If you cleanly shut down SQL server there should be no issue
http://msdn.microsoft.com/library/de...tart_6628.asp,
but anything connected to the server would need to handle this loss.
John
"computermagic" <craig@.computermagic.net(donotspam)> wrote in message
news:716D85E1-E2E7-4EFA-9201-0CFF53556126@.microsoft.com...
> SQL 2000 patched up running under SBS2003
> we shutdown and reboot automatically at 2AM into DOS and backup entire
> server via Ghost onto a backup and drive and restart server
> Question: are there any issues with rebooting SQL daily?
> a another consultant claims there are but I can find no mentions in MS db
> or
> literature.
> craig@.computermagic.net(donotspam)
|||The only issue is that you are blowing away your data cache and query cache,
so this is why queries in the morning run a lot more slowly than they do in
the afternoon.
Mike
Mentor
Solid Quality Learning
http://www.solidqualitylearning.com
"computermagic" <craig@.computermagic.net(donotspam)> wrote in message
news:716D85E1-E2E7-4EFA-9201-0CFF53556126@.microsoft.com...
> SQL 2000 patched up running under SBS2003
> we shutdown and reboot automatically at 2AM into DOS and backup entire
> server via Ghost onto a backup and drive and restart server
> Question: are there any issues with rebooting SQL daily?
> a another consultant claims there are but I can find no mentions in MS db
> or
> literature.
> craig@.computermagic.net(donotspam)

Nightly Maintenance Backup Plan fails -- no trace of why

We have been running a backup plan (created using the sql 2005 Maintenance wizard) for some time. It failed last night but all databases seemed to be backed up.

I looked at the ERRORLOG in <mssql2005>\mssql.1\log as well as

"Servname DB Backup Plan_20070118184358.txt"

but found no errors. Where else can I look to see what went wrong?

TIA,

barkingdog

You can also check the logs of the Sql Server Agent job corresponding to the maintenance plan.

Thanks,

Kuntal

|||

>>> check the logs of the Sql Server Agent job

Where are these located? (Are you referring to SQLAgent.OUT? It had nothing of interest.)

Barkingdog

|||

In Sql 2005, for every maintenance plan an Sql Agent job is created by the same name. You can view its logs as Sql Server Agent -> Jobs -> select the job & right click to View History.

Hope that helps

Kuntal

|||

What was the error under the scheduled job for this maintenance plan?

Also try to run thsi manually from SSMS to see the execution, also ensure the SQLAgent account has required privileges to run this job. ALso check what changes have been since last time when this job was running succesfsully.

Nightly maintenance

SQL Server 2000
I have finally been tasked and given access to the maintenance plans ...
only there aren't any (including disk defrags)! Backups are done via an
SQLagent job, but that's it.
Normally I would just whomp the defaults together and start them running,
but this is a 24x7x365 system and I'm not sure which of the jobs have the
potential to lock a table, or an index.
Advice, or links to docs that concern maintenance on a 24x7x365 system.
Also, in Management Studio the maintenance plans are under a Legacy heading
and I haven't seen where maintenance is defined in 2005. What's up with
that? Do I just need to dig deeper?
Thanks,
Jay> SQL Server 2000
> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't seen
> where maintenance is defined in 2005.
Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on 2000, since
they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's under the legacy
folder, quite simply?
Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does it)
will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm not sure
about what level of locking it is using in 2000, but that should be documented in the 2000 Books
Online).
I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could be
worth spending a few minutes with Google to try to dig it up...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
> SQL Server 2000
> I have finally been tasked and given access to the maintenance plans ... only there aren't any
> (including disk defrags)! Backups are done via an SQLagent job, but that's it.
> Normally I would just whomp the defaults together and start them running, but this is a 24x7x365
> system and I'm not sure which of the jobs have the potential to lock a table, or an index.
> Advice, or links to docs that concern maintenance on a 24x7x365 system.
> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't seen
> where maintenance is defined in 2005. What's up with that? Do I just need to dig deeper?
> Thanks,
> Jay
>|||I wasn't able to find much with an internet search, but digging in BOL I
found a lot.
Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
Am I missing anything?
Am I doing more than is needed?
Did I miss something in BOL that makes this plan risky?
Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG,
INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be run either before,
or after the application maintenance (archiving, credit card batches, search
engine data dumps, etc).
At no time will I allow an automated program shrink anything in the Windows
filesystem (and I hope I can keep anything from Auto Growing too).
Write a single stored procedure with an outer loop on DB's from
master..sysdatabases
Start with DBCC CHECKDB('dbname') looping through all databases. According
to BOL, if you don't specify any of the check options, nothing is locked and
on the dev server, it is taking about 2-3 minutes to complete. The only
possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but
will probably go with no arguments.
Within the loop, after a success on the CHECKDB (failure would exit the loop
and complain) run a script based on the one in 2000 BOL (DBCC SHOWCONTIG)
that does an INDEXDEFRAG on the index (BOL says this is an online
operation).
Last, run the SQL from BOL to loop on when statistics were last updated:
SELECT 'Index Name' = i.name,
'Statistics Date' = STATS_DATE(i.id, i.indid)
FROM sysobjects o, sysindexes i
WHERE o.name = '_table_name_'
AND o.id = i.id
and update any old statistics.
Done.
Now, I'm not really sure how to decide what statistics are old. Under
Informix I had a counter that measured insert/update activity since the last
statistics update. Perhaps just do everything nightly?
I'm also not sure how the "Auto Create Statistics" checkbox on the database
prosperities/options tab interacts with update statistics.
Thanks,
Jay
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
> Seems you are using SSMS to connect to a 2000 instance. There are no "new
> style" MP's on 2000, since they didn't exist in ... 2000. So perhaps SSMS
> are showing 2000 (old style) MP's under the legacy folder, quite simply?
> Be care full especially with rebuilding indexes. Rebuilding an index (the
> way 2000 MP's does it) will log the table during the index rebuild. Also,
> DBCC CHECKDB will use resources (I'm not sure about what level of locking
> it is using in 2000, but that should be documented in the 2000 Books
> Online).
> I believe that there's an "Operational Guideline" for 2000 available on
> the MS web. It could be worth spending a few minutes with Google to try to
> dig it up...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans ...
>> only there aren't any (including disk defrags)! Backups are done via an
>> SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them running,
>> but this is a 24x7x365 system and I'm not sure which of the jobs have the
>> potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005. What's
>> up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>|||It certainly seems you grasp the topic well. Some comments:
> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will it
terminate the batch so nothing further is executed? I can't answer that offhand, so thinking this
through and testing is important.
You might want to deliberately crash a database so that CHEDB fails to test this realistically. I
usually hack sysindexes (modify for instance the FirstIAM column for some row to some rubbish
value) - in a test database of course. You aren't allowed to update system tables directly by
default but read about sp_configure and you will probably figure out how to do it (I don't want to
post any more descriptive instructions considering this is a public forum).
Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a TSQL
job step will actually terminate the execution on any error (as I recall it). So, you might want to
schedule a CmdExec job step instead and call OSQL.EXE for the execution of your proc.
> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will probably
> go with no arguments.
Yes, go with as complete check as you can live with. If that doesn't work for you use any of the
options, possibly conditionally based on for instance week day (like do full every Sunday). Btw,
here's a *great* blog on CHECKDB and related topics:
http://blogs.msdn.com/sqlserverstorageengine/default.aspx
> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run a
> script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL
> says this is an online operation).
Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation really
hurts you at the table/index level and have conditional handling based on that, but that is probably
overkill. Same goes for the fillfactor value. You can't specify a fillfactor value for INDEXDEFRAG,
it will re-apply the value you specified when you created the index. If you want to read up on this
topic, check out http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also,
be aware of implications of defragging regarding transaction logging too (so you don't be surprised
that the following log backup is potentially huge). And read up on recovery models so you understand
all three.
> Last, run the SQL from BOL to loop on when statistics were last updated:
> and update any old statistics.
First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes with the
index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
Also, the database setting "auto update statistics" means that SQL Server *will update statistics by
itself*, as they becomes stale. Now, doing a manual update doesn't hurt, especially if you have the
time to use FULLSCAN (see UPDATE STATISTICS command). In most cases, this database setting should be
left to the default value. SQL Server uses a value in sysindexes, rowmodctr (I believe) to determine
how many modifications and whether it is time to auto-update (when a plan is to be re-used or
generated). This is a rather big topic, so here comes another WP:
http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there is one for 2000 as well, I
don't have that URL handy, but this is readable even if you aren't on 2005).
Note that the auto-create statistics option isn't the same as auto-update. Auto-create means that
the optimizer will *create* statistics on non-indexed columns when it feels that such statistics
would be useful. Such statistics are also auto-updated by the engine by the same handling as
described above (the auto-update setting).
Finally, instead of having this loop, consider creating a table, in which you have a row for each
database, and here you configure what actions are to be performed. Then you loop that table instead
of sysdatabases. I'm not saying it is better, all depends on ones particular requirements etc.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
> Am I missing anything?
> Am I doing more than is needed?
> Did I miss something in BOL that makes this plan risky?
> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG, STATS_DATE
> & UPDATE STATISTICS. It would be run either before, or after the application maintenance
> (archiving, credit card batches, search engine data dumps, etc).
> At no time will I allow an automated program shrink anything in the Windows filesystem (and I hope
> I can keep anything from Auto Growing too).
> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you don't
> specify any of the check options, nothing is locked and on the dev server, it is taking about 2-3
> minutes to complete. The only possible arguments I'm considering are NOINDEX and WITH
> PHYSICAL_ONLY, but will probably go with no arguments.
> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run a
> script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL
> says this is an online operation).
> Last, run the SQL from BOL to loop on when statistics were last updated:
> SELECT 'Index Name' = i.name,
> 'Statistics Date' = STATS_DATE(i.id, i.indid)
> FROM sysobjects o, sysindexes i
> WHERE o.name = '_table_name_'
> AND o.id = i.id
> and update any old statistics.
> Done.
> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a counter
> that measured insert/update activity since the last statistics update. Perhaps just do everything
> nightly?
> I'm also not sure how the "Auto Create Statistics" checkbox on the database prosperities/options
> tab interacts with update statistics.
> Thanks,
> Jay
>
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't seen
>> where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on 2000,
>> since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's under the
>> legacy folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does it)
>> will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm not sure
>> about what level of locking it is using in 2000, but that should be documented in the 2000 Books
>> Online).
>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could be
>> worth spending a few minutes with Google to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans ... only there aren't any
>> (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them running, but this is a 24x7x365
>> system and I'm not sure which of the jobs have the potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't seen
>> where maintenance is defined in 2005. What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>|||Well now. Just my first read took 10 minutes, never mind fully comprehending
and following the links.
Thank you very much for the time you spent on the reply Tibor and rest
assured, the time a cat would spend picking apart a fish is nothing,
compared to what I'm going to do with it.
Just a couple comments for now:
I grasp the topic well because I was an Informix DBA for 15 years and it's
the same song, just a different tune.
I write all production destined code with strong error checks and find ways
to make it complain loudly is something unexpected/unwanted happens (plus a
once a week ping).
I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX
because it is an offline procedure (24x7 after all). I do remember a rather
large discussion on this subject from about 6 months ago, but it doesn't
really matter, because if I get any scheduled maintenance, it will be
infrequent and limited.
Thanks,
Jay
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
> Watch out for exceptions. What happens if for instance CHECKDB encounters
> a corruption? Will it terminate the batch so nothing further is executed?
> I can't answer that offhand, so thinking this through and testing is
> important.
> You might want to deliberately crash a database so that CHEDB fails to
> test this realistically. I usually hack sysindexes (modify for instance
> the FirstIAM column for some row to some rubbish value) - in a test
> database of course. You aren't allowed to update system tables directly by
> default but read about sp_configure and you will probably figure out how
> to do it (I don't want to post any more descriptive instructions
> considering this is a public forum).
> Also, consider the client application handling of exceptions. SQL Server
> Agent is nice, but a TSQL job step will actually terminate the execution
> on any error (as I recall it). So, you might want to schedule a CmdExec
> job step instead and call OSQL.EXE for the execution of your proc.
>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
> Yes, go with as complete check as you can live with. If that doesn't work
> for you use any of the options, possibly conditionally based on for
> instance week day (like do full every Sunday). Btw, here's a *great* blog
> on CHECKDB and related topics:
> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
> Yep, sounds fine. I guess you could spend lots of time with analyzing how
> much fragmentation really hurts you at the table/index level and have
> conditional handling based on that, but that is probably overkill. Same
> goes for the fillfactor value. You can't specify a fillfactor value for
> INDEXDEFRAG, it will re-apply the value you specified when you created the
> index. If you want to read up on this topic, check out
> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
> Also, be aware of implications of defragging regarding transaction logging
> too (so you don't be surprised that the following log backup is
> potentially huge). And read up on recovery models so you understand all
> three.
>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
> First, be aware that if you rebuild (DBREINDEX) your indexes then the
> statistics that comes with the index will also be rebuilt. This does not
> happen if you INDEXDEFRAG, though.
> Also, the database setting "auto update statistics" means that SQL Server
> *will update statistics by itself*, as they becomes stale. Now, doing a
> manual update doesn't hurt, especially if you have the time to use
> FULLSCAN (see UPDATE STATISTICS command). In most cases, this database
> setting should be left to the default value. SQL Server uses a value in
> sysindexes, rowmodctr (I believe) to determine how many modifications and
> whether it is time to auto-update (when a plan is to be re-used or
> generated). This is a rather big topic, so here comes another WP:
> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there
> is one for 2000 as well, I don't have that URL handy, but this is readable
> even if you aren't on 2005).
> Note that the auto-create statistics option isn't the same as auto-update.
> Auto-create means that the optimizer will *create* statistics on
> non-indexed columns when it feels that such statistics would be useful.
> Such statistics are also auto-updated by the engine by the same handling
> as described above (the auto-update setting).
> Finally, instead of having this loop, consider creating a table, in which
> you have a row for each database, and here you configure what actions are
> to be performed. Then you loop that table instead of sysdatabases. I'm not
> saying it is better, all depends on ones particular requirements etc.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I
>>found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be run
>> either before, or after the application maintenance (archiving, credit
>> card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options, nothing
>> is locked and on the dev server, it is taking about 2-3 minutes to
>> complete. The only possible arguments I'm considering are NOINDEX and
>> WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since the
>> last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy folder,
>> quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index rebuild.
>> Also, DBCC CHECKDB will use resources (I'm not sure about what level of
>> locking it is using in 2000, but that should be documented in the 2000
>> Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on
>> the MS web. It could be worth spending a few minutes with Google to try
>> to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans
>> ... only there aren't any (including disk defrags)! Backups are done
>> via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them
>> running, but this is a 24x7x365 system and I'm not sure which of the
>> jobs have the potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005. What's
>> up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>|||> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
You're welcome. The links are good reading, so do check them when you have the time.
> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just a
> different tune.
Yes, I figured that from your earlier reply and the follow-up questions etc you had. Having that
background, I doubt you will have difficulties with the links I posted.
> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
> offline procedure (24x7 after all).
I figured that. I mostly wanted to mention the transaction logging aspect and differences between
the two, in conjunction with the recovery model. Often overlooked. When you go to 2005, you can play
with the ONLINE option for ALTER INDEX REBUILD (same as DBREINDEX in 2000). For instance reorganize
if you have fragmentation less than say 30%, else rebuild. This new ONLINE option isn't a panacea,
though, but it is one more tool in the box.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
> Well now. Just my first read took 10 minutes, never mind fully comprehending and following the
> links.
> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
> Just a couple comments for now:
> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just a
> different tune.
> I write all production destined code with strong error checks and find ways to make it complain
> loudly is something unexpected/unwanted happens (plus a once a week ping).
> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
> offline procedure (24x7 after all). I do remember a rather large discussion on this subject from
> about 6 months ago, but it doesn't really matter, because if I get any scheduled maintenance, it
> will be infrequent and limited.
> Thanks,
> Jay
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will it
>> terminate the batch so nothing further is executed? I can't answer that offhand, so thinking this
>> through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to test this realistically. I
>> usually hack sysindexes (modify for instance the FirstIAM column for some row to some rubbish
>> value) - in a test database of course. You aren't allowed to update system tables directly by
>> default but read about sp_configure and you will probably figure out how to do it (I don't want
>> to post any more descriptive instructions considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a
>> TSQL job step will actually terminate the execution on any error (as I recall it). So, you might
>> want to schedule a CmdExec job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will
>> probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work for you use any of the
>> options, possibly conditionally based on for instance week day (like do full every Sunday). Btw,
>> here's a *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run a
>> script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL
>> says this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation
>> really hurts you at the table/index level and have conditional handling based on that, but that
>> is probably overkill. Same goes for the fillfactor value. You can't specify a fillfactor value
>> for INDEXDEFRAG, it will re-apply the value you specified when you created the index. If you want
>> to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also, be aware of
>> implications of defragging regarding transaction logging too (so you don't be surprised that the
>> following log backup is potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes with
>> the index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server *will update statistics
>> by itself*, as they becomes stale. Now, doing a manual update doesn't hurt, especially if you
>> have the time to use FULLSCAN (see UPDATE STATISTICS command). In most cases, this database
>> setting should be left to the default value. SQL Server uses a value in sysindexes, rowmodctr (I
>> believe) to determine how many modifications and whether it is time to auto-update (when a plan
>> is to be re-used or generated). This is a rather big topic, so here comes another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there is one for 2000 as well,
>> I don't have that URL handy, but this is readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as auto-update. Auto-create means that
>> the optimizer will *create* statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by the same handling as
>> described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which you have a row for each
>> database, and here you configure what actions are to be performed. Then you loop that table
>> instead of sysdatabases. I'm not saying it is better, all depends on ones particular requirements
>> etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG,
>> STATS_DATE & UPDATE STATISTICS. It would be run either before, or after the application
>> maintenance (archiving, credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the Windows filesystem (and I
>> hope I can keep anything from Auto Growing too).
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you don't
>> specify any of the check options, nothing is locked and on the dev server, it is taking about
>> 2-3 minutes to complete. The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run a
>> script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL
>> says this is an online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a counter
>> that measured insert/update activity since the last statistics update. Perhaps just do
>> everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the database prosperities/options
>> tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't seen
>> where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on 2000,
>> since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's under
>> the legacy folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does
>> it) will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm not
>> sure about what level of locking it is using in 2000, but that should be documented in the 2000
>> Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could be
>> worth spending a few minutes with Google to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans ... only there aren't any
>> (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them running, but this is a
>> 24x7x365 system and I'm not sure which of the jobs have the potential to lock a table, or an
>> index.
>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't seen
>> where maintenance is defined in 2005. What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>|||One point just hit me.
On the Wizard it says: "Update data optimization", but the routines I've
found only deal with indexes and statistics. Is this correct, or did I miss
one? Or, are the statistics the data portion?
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uQpth3b5HHA.464@.TK2MSFTNGP02.phx.gbl...
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
> You're welcome. The links are good reading, so do check them when you have
> the time.
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
> Yes, I figured that from your earlier reply and the follow-up questions
> etc you had. Having that background, I doubt you will have difficulties
> with the links I posted.
>
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all).
> I figured that. I mostly wanted to mention the transaction logging aspect
> and differences between the two, in conjunction with the recovery model.
> Often overlooked. When you go to 2005, you can play with the ONLINE option
> for ALTER INDEX REBUILD (same as DBREINDEX in 2000). For instance
> reorganize if you have fragmentation less than say 30%, else rebuild. This
> new ONLINE option isn't a panacea, though, but it is one more tool in the
> box.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and find
>> ways to make it complain loudly is something unexpected/unwanted happens
>> (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6 months
>> ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB
>> encounters a corruption? Will it terminate the batch so nothing further
>> is executed? I can't answer that offhand, so thinking this through and
>> testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server
>> Agent is nice, but a TSQL job step will actually terminate the execution
>> on any error (as I recall it). So, you might want to schedule a CmdExec
>> job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't
>> work for you use any of the options, possibly conditionally based on for
>> instance week day (like do full every Sunday). Btw, here's a *great*
>> blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing
>> how much fragmentation really hurts you at the table/index level and
>> have conditional handling based on that, but that is probably overkill.
>> Same goes for the fillfactor value. You can't specify a fillfactor value
>> for INDEXDEFRAG, it will re-apply the value you specified when you
>> created the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does not
>> happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL
>> Server *will update statistics by itself*, as they becomes stale. Now,
>> doing a manual update doesn't hurt, especially if you have the time to
>> use FULLSCAN (see UPDATE STATISTICS command). In most cases, this
>> database setting should be left to the default value. SQL Server uses a
>> value in sysindexes, rowmodctr (I believe) to determine how many
>> modifications and whether it is time to auto-update (when a plan is to
>> be re-used or generated). This is a rather big topic, so here comes
>> another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there
>> is one for 2000 as well, I don't have that URL handy, but this is
>> readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in
>> which you have a row for each database, and here you configure what
>> actions are to be performed. Then you loop that table instead of
>> sysdatabases. I'm not saying it is better, all depends on ones
>> particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I
>>found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be
>> run either before, or after the application maintenance (archiving,
>> credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options,
>> nothing is locked and on the dev server, it is taking about 2-3 minutes
>> to complete. The only possible arguments I'm considering are NOINDEX
>> and WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since the
>> last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy
>> folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about
>> what level of locking it is using in 2000, but that should be
>> documented in the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available
>> on the MS web. It could be worth spending a few minutes with Google to
>> try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans
>> ... only there aren't any (including disk defrags)! Backups are done
>> via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them
>> running, but this is a 24x7x365 system and I'm not sure which of the
>> jobs have the potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365
>> system.
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>>
>|||> On the Wizard it says: "Update data optimization",
I've never thought about those words in the wizard. The wizard exposes three options. Translated
into TSQL commands (top to bottom):
DBCC DBREINDEX
UPDATE STATISTICS
DBCC SHRINKDB See http://www.karaszi.com/SQLServer/info_dont_shrink.asp to find out what I think of
this one.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:OJX$RTc5HHA.1992@.TK2MSFTNGP03.phx.gbl...
> One point just hit me.
> On the Wizard it says: "Update data optimization", but the routines I've found only deal with
> indexes and statistics. Is this correct, or did I miss one? Or, are the statistics the data
> portion?
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:uQpth3b5HHA.464@.TK2MSFTNGP02.phx.gbl...
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> You're welcome. The links are good reading, so do check them when you have the time.
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just a
>> different tune.
>> Yes, I figured that from your earlier reply and the follow-up questions etc you had. Having that
>> background, I doubt you will have difficulties with the links I posted.
>>
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all).
>> I figured that. I mostly wanted to mention the transaction logging aspect and differences between
>> the two, in conjunction with the recovery model. Often overlooked. When you go to 2005, you can
>> play with the ONLINE option for ALTER INDEX REBUILD (same as DBREINDEX in 2000). For instance
>> reorganize if you have fragmentation less than say 30%, else rebuild. This new ONLINE option
>> isn't a panacea, though, but it is one more tool in the box.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully comprehending and following the
>> links.
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just a
>> different tune.
>> I write all production destined code with strong error checks and find ways to make it complain
>> loudly is something unexpected/unwanted happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all). I do remember a rather large discussion on this subject from
>> about 6 months ago, but it doesn't really matter, because if I get any scheduled maintenance, it
>> will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will it
>> terminate the batch so nothing further is executed? I can't answer that offhand, so thinking
>> this through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to test this realistically.
>> I usually hack sysindexes (modify for instance the FirstIAM column for some row to some rubbish
>> value) - in a test database of course. You aren't allowed to update system tables directly by
>> default but read about sp_configure and you will probably figure out how to do it (I don't want
>> to post any more descriptive instructions considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a
>> TSQL job step will actually terminate the execution on any error (as I recall it). So, you
>> might want to schedule a CmdExec job step instead and call OSQL.EXE for the execution of your
>> proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will
>> probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work for you use any of
>> the options, possibly conditionally based on for instance week day (like do full every Sunday).
>> Btw, here's a *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run
>> a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index
>> (BOL says this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation
>> really hurts you at the table/index level and have conditional handling based on that, but that
>> is probably overkill. Same goes for the fillfactor value. You can't specify a fillfactor value
>> for INDEXDEFRAG, it will re-apply the value you specified when you created the index. If you
>> want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also, be aware of
>> implications of defragging regarding transaction logging too (so you don't be surprised that
>> the following log backup is potentially huge). And read up on recovery models so you understand
>> all three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes
>> with the index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server *will update
>> statistics by itself*, as they becomes stale. Now, doing a manual update doesn't hurt,
>> especially if you have the time to use FULLSCAN (see UPDATE STATISTICS command). In most cases,
>> this database setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and whether it is time to
>> auto-update (when a plan is to be re-used or generated). This is a rather big topic, so here
>> comes another WP: http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there is
>> one for 2000 as well, I don't have that URL handy, but this is readable even if you aren't on
>> 2005).
>> Note that the auto-create statistics option isn't the same as auto-update. Auto-create means
>> that the optimizer will *create* statistics on non-indexed columns when it feels that such
>> statistics would be useful. Such statistics are also auto-updated by the engine by the same
>> handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which you have a row for
>> each database, and here you configure what actions are to be performed. Then you loop that
>> table instead of sysdatabases. I'm not saying it is better, all depends on ones particular
>> requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG,
>> STATS_DATE & UPDATE STATISTICS. It would be run either before, or after the application
>> maintenance (archiving, credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the Windows filesystem (and I
>> hope I can keep anything from Auto Growing too).
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you
>> don't specify any of the check options, nothing is locked and on the dev server, it is taking
>> about 2-3 minutes to complete. The only possible arguments I'm considering are NOINDEX and
>> WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run
>> a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index
>> (BOL says this is an online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a counter
>> that measured insert/update activity since the last statistics update. Perhaps just do
>> everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the database
>> prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>>> seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on
>> 2000, since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's
>> under the legacy folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does
>> it) will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm
>> not sure about what level of locking it is using in 2000, but that should be documented in
>> the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could
>> be worth spending a few minutes with Google to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance plans ... only there aren't
>>> any (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them running, but this is a
>>> 24x7x365 system and I'm not sure which of the jobs have the potential to lock a table, or an
>>> index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>>> seen where maintenance is defined in 2005. What's up with that? Do I just need to dig
>>> deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>
>>
>>
>|||Oh, I'll read the link later, but I knew your opinion (which mirrors my own)
even before seeing the name of the asp page.
On a side note, under Informix I was a big fan of raw partitions, as you
gained about 5% (or more) in performance (almost for free) and none of the
convenience issues in Windows were present (detach mainly). Also, there were
load balancing things you could do that would be very similar to defining
DPV's on one instance (the clause is named FRAGMENT BY - Yuck! But the
functionality is FANTASTIC!).
Anyway, this provides a fixed amount of drive space allocated to the
database engine and growing/shrinking becomes a non-issue.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:OhZrxUi5HHA.1184@.TK2MSFTNGP04.phx.gbl...
>> On the Wizard it says: "Update data optimization",
> I've never thought about those words in the wizard. The wizard exposes
> three options. Translated into TSQL commands (top to bottom):
> DBCC DBREINDEX
> UPDATE STATISTICS
> DBCC SHRINKDB See http://www.karaszi.com/SQLServer/info_dont_shrink.asp to
> find out what I think of this one.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:OJX$RTc5HHA.1992@.TK2MSFTNGP03.phx.gbl...
>> One point just hit me.
>> On the Wizard it says: "Update data optimization", but the routines I've
>> found only deal with indexes and statistics. Is this correct, or did I
>> miss one? Or, are the statistics the data portion?
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:uQpth3b5HHA.464@.TK2MSFTNGP02.phx.gbl...
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> You're welcome. The links are good reading, so do check them when you
>> have the time.
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> Yes, I figured that from your earlier reply and the follow-up questions
>> etc you had. Having that background, I doubt you will have difficulties
>> with the links I posted.
>>
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all).
>> I figured that. I mostly wanted to mention the transaction logging
>> aspect and differences between the two, in conjunction with the recovery
>> model. Often overlooked. When you go to 2005, you can play with the
>> ONLINE option for ALTER INDEX REBUILD (same as DBREINDEX in 2000). For
>> instance reorganize if you have fragmentation less than say 30%, else
>> rebuild. This new ONLINE option isn't a panacea, though, but it is one
>> more tool in the box.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and find
>> ways to make it complain loudly is something unexpected/unwanted
>> happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6 months
>> ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB
>> encounters a corruption? Will it terminate the batch so nothing
>> further is executed? I can't answer that offhand, so thinking this
>> through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for
>> instance the FirstIAM column for some row to some rubbish value) - in
>> a test database of course. You aren't allowed to update system tables
>> directly by default but read about sp_configure and you will probably
>> figure out how to do it (I don't want to post any more descriptive
>> instructions considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL
>> Server Agent is nice, but a TSQL job step will actually terminate the
>> execution on any error (as I recall it). So, you might want to
>> schedule a CmdExec job step instead and call OSQL.EXE for the
>> execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't
>> work for you use any of the options, possibly conditionally based on
>> for instance week day (like do full every Sunday). Btw, here's a
>> *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL
>> (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says
>> this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing
>> how much fragmentation really hurts you at the table/index level and
>> have conditional handling based on that, but that is probably
>> overkill. Same goes for the fillfactor value. You can't specify a
>> fillfactor value for INDEXDEFRAG, it will re-apply the value you
>> specified when you created the index. If you want to read up on this
>> topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup
>> is potentially huge). And read up on recovery models so you understand
>> all three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does
>> not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL
>> Server *will update statistics by itself*, as they becomes stale. Now,
>> doing a manual update doesn't hurt, especially if you have the time to
>> use FULLSCAN (see UPDATE STATISTICS command). In most cases, this
>> database setting should be left to the default value. SQL Server uses
>> a value in sysindexes, rowmodctr (I believe) to determine how many
>> modifications and whether it is time to auto-update (when a plan is to
>> be re-used or generated). This is a rather big topic, so here comes
>> another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>> (there is one for 2000 as well, I don't have that URL handy, but this
>> is readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine
>> by the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in
>> which you have a row for each database, and here you configure what
>> actions are to be performed. Then you loop that table instead of
>> sysdatabases. I'm not saying it is better, all depends on ones
>> particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL
>>I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be
>> run either before, or after the application maintenance (archiving,
>> credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options,
>> nothing is locked and on the dev server, it is taking about 2-3
>> minutes to complete. The only possible arguments I'm considering are
>> NOINDEX and WITH PHYSICAL_ONLY, but will probably go with no
>> arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL
>> (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says
>> this is an online operation).
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since
>> the last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>>>
>>> Seems you are using SSMS to connect to a 2000 instance. There are no
>>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>>> perhaps SSMS are showing 2000 (old style) MP's under the legacy
>>> folder, quite simply?
>>>
>>> Be care full especially with rebuilding indexes. Rebuilding an index
>>> (the way 2000 MP's does it) will log the table during the index
>>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about
>>> what level of locking it is using in 2000, but that should be
>>> documented in the 2000 Books Online).
>>>
>>> I believe that there's an "Operational Guideline" for 2000 available
>>> on the MS web. It could be worth spending a few minutes with Google
>>> to try to dig it up...
>>>
>>> --
>>> Tibor Karaszi, SQL Server MVP
>>> http://www.karaszi.com/sqlserver/default.asp
>>> http://sqlblog.com/blogs/tibor_karaszi
>>>
>>>
>>> "Jay" <nospam@.nospam.org> wrote in message
>>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance
>>> plans ... only there aren't any (including disk defrags)! Backups
>>> are done via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them
>>> running, but this is a 24x7x365 system and I'm not sure which of
>>> the jobs have the potential to lock a table, or an index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365
>>> system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>>> What's up with that? Do I just need to dig deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>>
>>
>>
>>
>>
>|||> On a side note, under Informix I was a big fan of raw partitions
You might or might not know that raw partitions are also available for SQL Server.
SQL Servers Unix heritage of SQL Server (Sybase), and before the "new architecture" we first had to
create "disk devices" and over these then create (allocate) the database. This was a bit of a mess,
but I think that the architecture might have made more sense in other OSs than Windows.
As of the new architecture (7.0), all this mess was simplified into what we have now. One drawback
is that the simplification allows for easier management, autogrow and shrink and as most nice
features, they can me miss- or over- used. And this is what we often see in the SQL Server world. So
what more experienced DBA does, on reasonably and large sized databases, are pre-allocate. No
surprise, I'm sure.
Even though raw partitions are available for SQL Server, I don't think I've even encountered anybody
using them. I vaguely recall some benchmark, talking about some 2-3 percent, but I believe that this
depends much on type of load, and also my memory might not serve me here. Perhaps raw partitions are
used in some of the benchmarks you see "out there", like TPC-C. Come to think about it, the vendors
really want to squeeze out the extreme for such benchmarks. So if you want to take the time and
study a few and *don't* see them using raw, you can be reasonably certain that it isn't worth even
remotely considering.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:%23oYl7jm5HHA.3916@.TK2MSFTNGP02.phx.gbl...
> Oh, I'll read the link later, but I knew your opinion (which mirrors my own) even before seeing
> the name of the asp page.
> On a side note, under Informix I was a big fan of raw partitions, as you gained about 5% (or more)
> in performance (almost for free) and none of the convenience issues in Windows were present
> (detach mainly). Also, there were load balancing things you could do that would be very similar to
> defining DPV's on one instance (the clause is named FRAGMENT BY - Yuck! But the functionality is
> FANTASTIC!).
> Anyway, this provides a fixed amount of drive space allocated to the database engine and
> growing/shrinking becomes a non-issue.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:OhZrxUi5HHA.1184@.TK2MSFTNGP04.phx.gbl...
>> On the Wizard it says: "Update data optimization",
>> I've never thought about those words in the wizard. The wizard exposes three options. Translated
>> into TSQL commands (top to bottom):
>> DBCC DBREINDEX
>> UPDATE STATISTICS
>> DBCC SHRINKDB See http://www.karaszi.com/SQLServer/info_dont_shrink.asp to find out what I think
>> of this one.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:OJX$RTc5HHA.1992@.TK2MSFTNGP03.phx.gbl...
>> One point just hit me.
>> On the Wizard it says: "Update data optimization", but the routines I've found only deal with
>> indexes and statistics. Is this correct, or did I miss one? Or, are the statistics the data
>> portion?
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:uQpth3b5HHA.464@.TK2MSFTNGP02.phx.gbl...
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> You're welcome. The links are good reading, so do check them when you have the time.
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just
>> a different tune.
>> Yes, I figured that from your earlier reply and the follow-up questions etc you had. Having
>> that background, I doubt you will have difficulties with the links I posted.
>>
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all).
>> I figured that. I mostly wanted to mention the transaction logging aspect and differences
>> between the two, in conjunction with the recovery model. Often overlooked. When you go to 2005,
>> you can play with the ONLINE option for ALTER INDEX REBUILD (same as DBREINDEX in 2000). For
>> instance reorganize if you have fragmentation less than say 30%, else rebuild. This new ONLINE
>> option isn't a panacea, though, but it is one more tool in the box.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully comprehending and following the
>> links.
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just
>> a different tune.
>> I write all production destined code with strong error checks and find ways to make it
>> complain loudly is something unexpected/unwanted happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all). I do remember a rather large discussion on this subject
>> from about 6 months ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will
>> it terminate the batch so nothing further is executed? I can't answer that offhand, so
>> thinking this through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to test this
>> realistically. I usually hack sysindexes (modify for instance the FirstIAM column for some
>> row to some rubbish value) - in a test database of course. You aren't allowed to update
>> system tables directly by default but read about sp_configure and you will probably figure
>> out how to do it (I don't want to post any more descriptive instructions considering this is
>> a public forum).
>> Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a
>> TSQL job step will actually terminate the execution on any error (as I recall it). So, you
>> might want to schedule a CmdExec job step instead and call OSQL.EXE for the execution of your
>> proc.
>>
>>> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will
>>> probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work for you use any of
>> the options, possibly conditionally based on for instance week day (like do full every
>> Sunday). Btw, here's a *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain)
>>> run a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the
>>> index (BOL says this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation
>> really hurts you at the table/index level and have conditional handling based on that, but
>> that is probably overkill. Same goes for the fillfactor value. You can't specify a fillfactor
>> value for INDEXDEFRAG, it will re-apply the value you specified when you created the index.
>> If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also, be aware
>> of implications of defragging regarding transaction logging too (so you don't be surprised
>> that the following log backup is potentially huge). And read up on recovery models so you
>> understand all three.
>>
>>> Last, run the SQL from BOL to loop on when statistics were last updated:
>>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes
>> with the index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server *will update
>> statistics by itself*, as they becomes stale. Now, doing a manual update doesn't hurt,
>> especially if you have the time to use FULLSCAN (see UPDATE STATISTICS command). In most
>> cases, this database setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and whether it is time
>> to auto-update (when a plan is to be re-used or generated). This is a rather big topic, so
>> here comes another WP: http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>> (there is one for 2000 as well, I don't have that URL handy, but this is readable even if you
>> aren't on 2005).
>> Note that the auto-create statistics option isn't the same as auto-update. Auto-create means
>> that the optimizer will *create* statistics on non-indexed columns when it feels that such
>> statistics would be useful. Such statistics are also auto-updated by the engine by the same
>> handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which you have a row for
>> each database, and here you configure what actions are to be performed. Then you loop that
>> table instead of sysdatabases. I'm not saying it is better, all depends on ones particular
>> requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
>>>
>>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
>>> Am I missing anything?
>>> Am I doing more than is needed?
>>> Did I miss something in BOL that makes this plan risky?
>>>
>>> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG,
>>> STATS_DATE & UPDATE STATISTICS. It would be run either before, or after the application
>>> maintenance (archiving, credit card batches, search engine data dumps, etc).
>>>
>>> At no time will I allow an automated program shrink anything in the Windows filesystem (and
>>> I hope I can keep anything from Auto Growing too).
>>>
>>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>>>
>>> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you
>>> don't specify any of the check options, nothing is locked and on the dev server, it is
>>> taking about 2-3 minutes to complete. The only possible arguments I'm considering are
>>> NOINDEX and WITH PHYSICAL_ONLY, but will probably go with no arguments.
>>>
>>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain)
>>> run a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the
>>> index (BOL says this is an online operation).
>>>
>>> Last, run the SQL from BOL to loop on when statistics were last updated:
>>>
>>> SELECT 'Index Name' = i.name,
>>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>>> FROM sysobjects o, sysindexes i
>>> WHERE o.name = '_table_name_'
>>> AND o.id = i.id
>>>
>>> and update any old statistics.
>>>
>>> Done.
>>>
>>> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a
>>> counter that measured insert/update activity since the last statistics update. Perhaps just
>>> do everything nightly?
>>>
>>> I'm also not sure how the "Auto Create Statistics" checkbox on the database
>>> prosperities/options tab interacts with update statistics.
>>>
>>> Thanks,
>>> Jay
>>>
>>>
>>>
>>>
>>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>>> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>>> seen where maintenance is defined in 2005.
>>>
>>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on
>>> 2000, since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style)
>>> MP's under the legacy folder, quite simply?
>>>
>>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's
>>> does it) will log the table during the index rebuild. Also, DBCC CHECKDB will use resources
>>> (I'm not sure about what level of locking it is using in 2000, but that should be
>>> documented in the 2000 Books Online).
>>>
>>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It
>>> could be worth spending a few minutes with Google to try to dig it up...
>>>
>>> --
>>> Tibor Karaszi, SQL Server MVP
>>> http://www.karaszi.com/sqlserver/default.asp
>>> http://sqlblog.com/blogs/tibor_karaszi
>>>
>>>
>>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance plans ... only there aren't
>>> any (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them running, but this is a
>>> 24x7x365 system and I'm not sure which of the jobs have the potential to lock a table, or
>>> an index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>>> seen where maintenance is defined in 2005. What's up with that? Do I just need to dig
>>> deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>>
>>>
>>>
>>
>>
>>
>|||Ya, I was aware of SQL Server raw partitions and didn't feel particularly
enthused about them, not sure why.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23IWwHvm5HHA.536@.TK2MSFTNGP06.phx.gbl...
>> On a side note, under Informix I was a big fan of raw partitions
> You might or might not know that raw partitions are also available for SQL
> Server.
> SQL Servers Unix heritage of SQL Server (Sybase), and before the "new
> architecture" we first had to create "disk devices" and over these then
> create (allocate) the database. This was a bit of a mess, but I think that
> the architecture might have made more sense in other OSs than Windows.
> As of the new architecture (7.0), all this mess was simplified into what
> we have now. One drawback is that the simplification allows for easier
> management, autogrow and shrink and as most nice features, they can me
> miss- or over- used. And this is what we often see in the SQL Server
> world. So what more experienced DBA does, on reasonably and large sized
> databases, are pre-allocate. No surprise, I'm sure.
> Even though raw partitions are available for SQL Server, I don't think
> I've even encountered anybody using them. I vaguely recall some benchmark,
> talking about some 2-3 percent, but I believe that this depends much on
> type of load, and also my memory might not serve me here. Perhaps raw
> partitions are used in some of the benchmarks you see "out there", like
> TPC-C. Come to think about it, the vendors really want to squeeze out the
> extreme for such benchmarks. So if you want to take the time and study a
> few and *don't* see them using raw, you can be reasonably certain that it
> isn't worth even remotely considering.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:%23oYl7jm5HHA.3916@.TK2MSFTNGP02.phx.gbl...
>> Oh, I'll read the link later, but I knew your opinion (which mirrors my
>> own) even before seeing the name of the asp page.
>> On a side note, under Informix I was a big fan of raw partitions, as you
>> gained about 5% (or more) in performance (almost for free) and none of
>> the convenience issues in Windows were present (detach mainly). Also,
>> there were load balancing things you could do that would be very similar
>> to defining DPV's on one instance (the clause is named FRAGMENT BY -
>> Yuck! But the functionality is FANTASTIC!).
>> Anyway, this provides a fixed amount of drive space allocated to the
>> database engine and growing/shrinking becomes a non-issue.
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:OhZrxUi5HHA.1184@.TK2MSFTNGP04.phx.gbl...
>> On the Wizard it says: "Update data optimization",
>> I've never thought about those words in the wizard. The wizard exposes
>> three options. Translated into TSQL commands (top to bottom):
>> DBCC DBREINDEX
>> UPDATE STATISTICS
>> DBCC SHRINKDB See http://www.karaszi.com/SQLServer/info_dont_shrink.asp
>> to find out what I think of this one.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:OJX$RTc5HHA.1992@.TK2MSFTNGP03.phx.gbl...
>> One point just hit me.
>> On the Wizard it says: "Update data optimization", but the routines
>> I've found only deal with indexes and statistics. Is this correct, or
>> did I miss one? Or, are the statistics the data portion?
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:uQpth3b5HHA.464@.TK2MSFTNGP02.phx.gbl...
>> Thank you very much for the time you spent on the reply Tibor and
>> rest assured, the time a cat would spend picking apart a fish is
>> nothing, compared to what I'm going to do with it.
>> You're welcome. The links are good reading, so do check them when you
>> have the time.
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> Yes, I figured that from your earlier reply and the follow-up
>> questions etc you had. Having that background, I doubt you will have
>> difficulties with the links I posted.
>>
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all).
>> I figured that. I mostly wanted to mention the transaction logging
>> aspect and differences between the two, in conjunction with the
>> recovery model. Often overlooked. When you go to 2005, you can play
>> with the ONLINE option for ALTER INDEX REBUILD (same as DBREINDEX in
>> 2000). For instance reorganize if you have fragmentation less than say
>> 30%, else rebuild. This new ONLINE option isn't a panacea, though, but
>> it is one more tool in the box.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and
>> rest assured, the time a cat would spend picking apart a fish is
>> nothing, compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and
>> find ways to make it complain loudly is something unexpected/unwanted
>> happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6
>> months ago, but it doesn't really matter, because if I get any
>> scheduled maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>>> It certainly seems you grasp the topic well. Some comments:
>>>
>>> Write a single stored procedure with an outer loop on DB's from
>>> master..sysdatabases
>>>
>>> Watch out for exceptions. What happens if for instance CHECKDB
>>> encounters a corruption? Will it terminate the batch so nothing
>>> further is executed? I can't answer that offhand, so thinking this
>>> through and testing is important.
>>>
>>> You might want to deliberately crash a database so that CHEDB fails
>>> to test this realistically. I usually hack sysindexes (modify for
>>> instance the FirstIAM column for some row to some rubbish value) -
>>> in a test database of course. You aren't allowed to update system
>>> tables directly by default but read about sp_configure and you will
>>> probably figure out how to do it (I don't want to post any more
>>> descriptive instructions considering this is a public forum).
>>>
>>> Also, consider the client application handling of exceptions. SQL
>>> Server Agent is nice, but a TSQL job step will actually terminate
>>> the execution on any error (as I recall it). So, you might want to
>>> schedule a CmdExec job step instead and call OSQL.EXE for the
>>> execution of your proc.
>>>
>>>
>>> The only possible arguments I'm considering are NOINDEX and WITH
>>> PHYSICAL_ONLY, but will probably go with no arguments.
>>>
>>> Yes, go with as complete check as you can live with. If that doesn't
>>> work for you use any of the options, possibly conditionally based on
>>> for instance week day (like do full every Sunday). Btw, here's a
>>> *great* blog on CHECKDB and related topics:
>>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>>
>>>
>>> Within the loop, after a success on the CHECKDB (failure would exit
>>> the loop and complain) run a script based on the one in 2000 BOL
>>> (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says
>>> this is an online operation).
>>>
>>> Yep, sounds fine. I guess you could spend lots of time with
>>> analyzing how much fragmentation really hurts you at the table/index
>>> level and have conditional handling based on that, but that is
>>> probably overkill. Same goes for the fillfactor value. You can't
>>> specify a fillfactor value for INDEXDEFRAG, it will re-apply the
>>> value you specified when you created the index. If you want to read
>>> up on this topic, check out
>>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>>> Also, be aware of implications of defragging regarding transaction
>>> logging too (so you don't be surprised that the following log backup
>>> is potentially huge). And read up on recovery models so you
>>> understand all three.
>>>
>>>
>>> Last, run the SQL from BOL to loop on when statistics were last
>>> updated:
>>> and update any old statistics.
>>>
>>> First, be aware that if you rebuild (DBREINDEX) your indexes then
>>> the statistics that comes with the index will also be rebuilt. This
>>> does not happen if you INDEXDEFRAG, though.
>>> Also, the database setting "auto update statistics" means that SQL
>>> Server *will update statistics by itself*, as they becomes stale.
>>> Now, doing a manual update doesn't hurt, especially if you have the
>>> time to use FULLSCAN (see UPDATE STATISTICS command). In most cases,
>>> this database setting should be left to the default value. SQL
>>> Server uses a value in sysindexes, rowmodctr (I believe) to
>>> determine how many modifications and whether it is time to
>>> auto-update (when a plan is to be re-used or generated). This is a
>>> rather big topic, so here comes another WP:
>>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>>> (there is one for 2000 as well, I don't have that URL handy, but
>>> this is readable even if you aren't on 2005).
>>> Note that the auto-create statistics option isn't the same as
>>> auto-update. Auto-create means that the optimizer will *create*
>>> statistics on non-indexed columns when it feels that such statistics
>>> would be useful. Such statistics are also auto-updated by the engine
>>> by the same handling as described above (the auto-update setting).
>>>
>>> Finally, instead of having this loop, consider creating a table, in
>>> which you have a row for each database, and here you configure what
>>> actions are to be performed. Then you loop that table instead of
>>> sysdatabases. I'm not saying it is better, all depends on ones
>>> particular requirements etc.
>>> --
>>> Tibor Karaszi, SQL Server MVP
>>> http://www.karaszi.com/sqlserver/default.asp
>>> http://sqlblog.com/blogs/tibor_karaszi
>>>
>>>
>>> "Jay" <nospam@.nospam.org> wrote in message
>>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>>I wasn't able to find much with an internet search, but digging in
>>>BOL I found a lot.
>>>
>>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>>> backup)?
>>> Am I missing anything?
>>> Am I doing more than is needed?
>>> Did I miss something in BOL that makes this plan risky?
>>>
>>> Here is my intended plan: write a procedure that uses CHECKDB,
>>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would
>>> be run either before, or after the application maintenance
>>> (archiving, credit card batches, search engine data dumps, etc).
>>>
>>> At no time will I allow an automated program shrink anything in the
>>> Windows filesystem (and I hope I can keep anything from Auto
>>> Growing too).
>>>
>>> Write a single stored procedure with an outer loop on DB's from
>>> master..sysdatabases
>>>
>>> Start with DBCC CHECKDB('dbname') looping through all databases.
>>> According to BOL, if you don't specify any of the check options,
>>> nothing is locked and on the dev server, it is taking about 2-3
>>> minutes to complete. The only possible arguments I'm considering
>>> are NOINDEX and WITH PHYSICAL_ONLY, but will probably go with no
>>> arguments.
>>>
>>> Within the loop, after a success on the CHECKDB (failure would exit
>>> the loop and complain) run a script based on the one in 2000 BOL
>>> (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says
>>> this is an online operation).
>>>
>>> Last, run the SQL from BOL to loop on when statistics were last
>>> updated:
>>>
>>> SELECT 'Index Name' = i.name,
>>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>>> FROM sysobjects o, sysindexes i
>>> WHERE o.name = '_table_name_'
>>> AND o.id = i.id
>>>
>>> and update any old statistics.
>>>
>>> Done.
>>>
>>> Now, I'm not really sure how to decide what statistics are old.
>>> Under Informix I had a counter that measured insert/update activity
>>> since the last statistics update. Perhaps just do everything
>>> nightly?
>>>
>>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>>> database prosperities/options tab interacts with update statistics.
>>>
>>> Thanks,
>>> Jay
>>>
>>>
>>>
>>>
>>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>>> SQL Server 2000
>>>> Also, in Management Studio the maintenance plans are under a
>>>> Legacy heading and I haven't seen where maintenance is defined in
>>>> 2005.
>>>
>>> Seems you are using SSMS to connect to a 2000 instance. There are
>>> no "new style" MP's on 2000, since they didn't exist in ... 2000.
>>> So perhaps SSMS are showing 2000 (old style) MP's under the legacy
>>> folder, quite simply?
>>>
>>> Be care full especially with rebuilding indexes. Rebuilding an
>>> index (the way 2000 MP's does it) will log the table during the
>>> index rebuild. Also, DBCC CHECKDB will use resources (I'm not sure
>>> about what level of locking it is using in 2000, but that should
>>> be documented in the 2000 Books Online).
>>>
>>> I believe that there's an "Operational Guideline" for 2000
>>> available on the MS web. It could be worth spending a few minutes
>>> with Google to try to dig it up...
>>>
>>> --
>>> Tibor Karaszi, SQL Server MVP
>>> http://www.karaszi.com/sqlserver/default.asp
>>> http://sqlblog.com/blogs/tibor_karaszi
>>>
>>>
>>> "Jay" <nospam@.nospam.org> wrote in message
>>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>>> SQL Server 2000
>>>>
>>>> I have finally been tasked and given access to the maintenance
>>>> plans ... only there aren't any (including disk defrags)! Backups
>>>> are done via an SQLagent job, but that's it.
>>>>
>>>> Normally I would just whomp the defaults together and start them
>>>> running, but this is a 24x7x365 system and I'm not sure which of
>>>> the jobs have the potential to lock a table, or an index.
>>>>
>>>> Advice, or links to docs that concern maintenance on a 24x7x365
>>>> system.
>>>>
>>>> Also, in Management Studio the maintenance plans are under a
>>>> Legacy heading and I haven't seen where maintenance is defined in
>>>> 2005. What's up with that? Do I just need to dig deeper?
>>>>
>>>> Thanks,
>>>> Jay
>>>>
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>|||Oh my, I hit a snag right out of the gate.
I wanted to execute DBCC CHECKDB and add program logic to determine
success/failure as I recalled code that put DBCC results into a temp table.
Oops, no TABLERESULTS option. So, the messages are always displayed and I
can't get them into a data structure.
When I change the database name to something that doesn't exist, the
procedure aborts (is this what the OSQL was for?) and I never get to the
line 'PRINT @.@.ERROR'.
I see the @.@.ERROR variable, but expected a SET option to change the default
behavior of immediately aborting - can't find anything.
Just a reminder: 2000.
"Jay" <nospam@.nospam.org> wrote in message
news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
> Well now. Just my first read took 10 minutes, never mind fully
> comprehending and following the links.
> Thank you very much for the time you spent on the reply Tibor and rest
> assured, the time a cat would spend picking apart a fish is nothing,
> compared to what I'm going to do with it.
> Just a couple comments for now:
> I grasp the topic well because I was an Informix DBA for 15 years and it's
> the same song, just a different tune.
> I write all production destined code with strong error checks and find
> ways to make it complain loudly is something unexpected/unwanted happens
> (plus a once a week ping).
> I chose INDEXDEFRAG because it is an online procedure and avoided
> DBREINDEX because it is an offline procedure (24x7 after all). I do
> remember a rather large discussion on this subject from about 6 months
> ago, but it doesn't really matter, because if I get any scheduled
> maintenance, it will be infrequent and limited.
> Thanks,
> Jay
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters
>> a corruption? Will it terminate the batch so nothing further is executed?
>> I can't answer that offhand, so thinking this through and testing is
>> important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server
>> Agent is nice, but a TSQL job step will actually terminate the execution
>> on any error (as I recall it). So, you might want to schedule a CmdExec
>> job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work
>> for you use any of the options, possibly conditionally based on for
>> instance week day (like do full every Sunday). Btw, here's a *great* blog
>> on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how
>> much fragmentation really hurts you at the table/index level and have
>> conditional handling based on that, but that is probably overkill. Same
>> goes for the fillfactor value. You can't specify a fillfactor value for
>> INDEXDEFRAG, it will re-apply the value you specified when you created
>> the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does not
>> happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server
>> *will update statistics by itself*, as they becomes stale. Now, doing a
>> manual update doesn't hurt, especially if you have the time to use
>> FULLSCAN (see UPDATE STATISTICS command). In most cases, this database
>> setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and
>> whether it is time to auto-update (when a plan is to be re-used or
>> generated). This is a rather big topic, so here comes another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there
>> is one for 2000 as well, I don't have that URL handy, but this is
>> readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which
>> you have a row for each database, and here you configure what actions are
>> to be performed. Then you loop that table instead of sysdatabases. I'm
>> not saying it is better, all depends on ones particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I
>>found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be run
>> either before, or after the application maintenance (archiving, credit
>> card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options, nothing
>> is locked and on the dev server, it is taking about 2-3 minutes to
>> complete. The only possible arguments I'm considering are NOINDEX and
>> WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since the
>> last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy folder,
>> quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about what
>> level of locking it is using in 2000, but that should be documented in
>> the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on
>> the MS web. It could be worth spending a few minutes with Google to try
>> to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans
>> ... only there aren't any (including disk defrags)! Backups are done
>> via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them
>> running, but this is a 24x7x365 system and I'm not sure which of the
>> jobs have the potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365
>> system.
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>|||Never mind.
On a hunch I added WITH TABLERESULTS, which BOL doesn't say will work. But
it does.
"Jay" <nospam@.nospam.org> wrote in message
news:es7RLHn5HHA.5164@.TK2MSFTNGP05.phx.gbl...
> Oh my, I hit a snag right out of the gate.
> I wanted to execute DBCC CHECKDB and add program logic to determine
> success/failure as I recalled code that put DBCC results into a temp
> table. Oops, no TABLERESULTS option. So, the messages are always displayed
> and I can't get them into a data structure.
> When I change the database name to something that doesn't exist, the
> procedure aborts (is this what the OSQL was for?) and I never get to the
> line 'PRINT @.@.ERROR'.
> I see the @.@.ERROR variable, but expected a SET option to change the
> default behavior of immediately aborting - can't find anything.
> Just a reminder: 2000.
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and find
>> ways to make it complain loudly is something unexpected/unwanted happens
>> (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6 months
>> ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB
>> encounters a corruption? Will it terminate the batch so nothing further
>> is executed? I can't answer that offhand, so thinking this through and
>> testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server
>> Agent is nice, but a TSQL job step will actually terminate the execution
>> on any error (as I recall it). So, you might want to schedule a CmdExec
>> job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't
>> work for you use any of the options, possibly conditionally based on for
>> instance week day (like do full every Sunday). Btw, here's a *great*
>> blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing
>> how much fragmentation really hurts you at the table/index level and
>> have conditional handling based on that, but that is probably overkill.
>> Same goes for the fillfactor value. You can't specify a fillfactor value
>> for INDEXDEFRAG, it will re-apply the value you specified when you
>> created the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does not
>> happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL
>> Server *will update statistics by itself*, as they becomes stale. Now,
>> doing a manual update doesn't hurt, especially if you have the time to
>> use FULLSCAN (see UPDATE STATISTICS command). In most cases, this
>> database setting should be left to the default value. SQL Server uses a
>> value in sysindexes, rowmodctr (I believe) to determine how many
>> modifications and whether it is time to auto-update (when a plan is to
>> be re-used or generated). This is a rather big topic, so here comes
>> another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there
>> is one for 2000 as well, I don't have that URL handy, but this is
>> readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in
>> which you have a row for each database, and here you configure what
>> actions are to be performed. Then you loop that table instead of
>> sysdatabases. I'm not saying it is better, all depends on ones
>> particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I
>>found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be
>> run either before, or after the application maintenance (archiving,
>> credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options,
>> nothing is locked and on the dev server, it is taking about 2-3 minutes
>> to complete. The only possible arguments I'm considering are NOINDEX
>> and WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since the
>> last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy
>> folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about
>> what level of locking it is using in 2000, but that should be
>> documented in the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available
>> on the MS web. It could be worth spending a few minutes with Google to
>> try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans
>> ... only there aren't any (including disk defrags)! Backups are done
>> via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them
>> running, but this is a 24x7x365 system and I'm not sure which of the
>> jobs have the potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365
>> system.
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>>
>|||> I wanted to execute DBCC CHECKDB and add program logic to determine success/failure as I recalled
> code that put DBCC results into a temp table. Oops, no TABLERESULTS option. So, the messages are
> always displayed and I can't get them into a data structure.
Some DBCCs has TABLERESULTS even though it isn't documented. But I'm hesitant to recommend using
that (if such exist on 2000 for DBCC CHECKDB) since if it isn't documented, then it isn't supported.
> When I change the database name to something that doesn't exist, the procedure aborts (is this
> what the OSQL was for?) and I never get to the line 'PRINT @.@.ERROR'.
Exception handling is a bit of a mess in TSQL. First, you have the engine behavior. Some errors will
terminate the batch (procedure). Not much you can do if that happens.
But, the Agent scheduler for TSQL jobsteps has some extra toppings where it terminates the job if
any error with severity > 10 (as I remember it). This last thing is what I suggested OSQL for.
Now, if you execute it from Query Analyzer and it terminates the batch, then OSQL won't help you.
But I'm surprised. Try below. On my machine, the PRINT statement *is* executed. Do you see something
different? Make sure you execute into text if you use Query Analyzer. Perhaps this is a change
between 2000 and 2005?
ALTER PROC p AS
DBCC CHECKDB('ds') WITH TABLERESULTS
PRINT 'Hello'
GO
EXEC p
No SET option, I'm afraid. In the end, you migtht be better off using a client language (like VB.NET
or C#.NET) for this, if you can't get the exception handling to your liking.
As for the API to use, DMO is designed particularly for admin, but I'm not sure you can get to all
the error messages that CHECKDB might return. At least this was the case when I used DMO many many
years ago. If that is the case, consider ADO.NET which should have something like an error colection
which you can loop through. Or whatever DB API you or some colleague of yours are most experienced
in (ODBC etc).
There are a couple of great error handling articles at http://www.sommarskog.se/.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:es7RLHn5HHA.5164@.TK2MSFTNGP05.phx.gbl...
> Oh my, I hit a snag right out of the gate.
> I wanted to execute DBCC CHECKDB and add program logic to determine success/failure as I recalled
> code that put DBCC results into a temp table. Oops, no TABLERESULTS option. So, the messages are
> always displayed and I can't get them into a data structure.
> When I change the database name to something that doesn't exist, the procedure aborts (is this
> what the OSQL was for?) and I never get to the line 'PRINT @.@.ERROR'.
> I see the @.@.ERROR variable, but expected a SET option to change the default behavior of
> immediately aborting - can't find anything.
> Just a reminder: 2000.
>
> "Jay" <nospam@.nospam.org> wrote in message news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully comprehending and following the
>> links.
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just a
>> different tune.
>> I write all production destined code with strong error checks and find ways to make it complain
>> loudly is something unexpected/unwanted happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all). I do remember a rather large discussion on this subject from
>> about 6 months ago, but it doesn't really matter, because if I get any scheduled maintenance, it
>> will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will it
>> terminate the batch so nothing further is executed? I can't answer that offhand, so thinking
>> this through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to test this realistically.
>> I usually hack sysindexes (modify for instance the FirstIAM column for some row to some rubbish
>> value) - in a test database of course. You aren't allowed to update system tables directly by
>> default but read about sp_configure and you will probably figure out how to do it (I don't want
>> to post any more descriptive instructions considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a
>> TSQL job step will actually terminate the execution on any error (as I recall it). So, you might
>> want to schedule a CmdExec job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will
>> probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work for you use any of the
>> options, possibly conditionally based on for instance week day (like do full every Sunday). Btw,
>> here's a *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run
>> a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index
>> (BOL says this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation
>> really hurts you at the table/index level and have conditional handling based on that, but that
>> is probably overkill. Same goes for the fillfactor value. You can't specify a fillfactor value
>> for INDEXDEFRAG, it will re-apply the value you specified when you created the index. If you
>> want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also, be aware of
>> implications of defragging regarding transaction logging too (so you don't be surprised that the
>> following log backup is potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes with
>> the index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server *will update
>> statistics by itself*, as they becomes stale. Now, doing a manual update doesn't hurt,
>> especially if you have the time to use FULLSCAN (see UPDATE STATISTICS command). In most cases,
>> this database setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and whether it is time to
>> auto-update (when a plan is to be re-used or generated). This is a rather big topic, so here
>> comes another WP: http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there is
>> one for 2000 as well, I don't have that URL handy, but this is readable even if you aren't on
>> 2005).
>> Note that the auto-create statistics option isn't the same as auto-update. Auto-create means
>> that the optimizer will *create* statistics on non-indexed columns when it feels that such
>> statistics would be useful. Such statistics are also auto-updated by the engine by the same
>> handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which you have a row for
>> each database, and here you configure what actions are to be performed. Then you loop that table
>> instead of sysdatabases. I'm not saying it is better, all depends on ones particular
>> requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG,
>> STATS_DATE & UPDATE STATISTICS. It would be run either before, or after the application
>> maintenance (archiving, credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the Windows filesystem (and I
>> hope I can keep anything from Auto Growing too).
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you don't
>> specify any of the check options, nothing is locked and on the dev server, it is taking about
>> 2-3 minutes to complete. The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run
>> a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index
>> (BOL says this is an online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a counter
>> that measured insert/update activity since the last statistics update. Perhaps just do
>> everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the database
>> prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>> seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on 2000,
>> since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's under
>> the legacy folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does
>> it) will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm
>> not sure about what level of locking it is using in 2000, but that should be documented in the
>> 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could
>> be worth spending a few minutes with Google to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans ... only there aren't
>> any (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them running, but this is a
>> 24x7x365 system and I'm not sure which of the jobs have the potential to lock a table, or an
>> index.
>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>> seen where maintenance is defined in 2005. What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>>
>|||> ALTER PROC p AS
> DBCC CHECKDB('ds') WITH TABLERESULTS
> PRINT 'Hello'
> GO
> EXEC p
"Hello" only prints on a 2005 engine, not on a 2000.
Since the majority of the time everything will be fine, I'll let it fail and
(if I can) get the engine to email me. Otherwise, I'll put something
together that expects entries on success and will complain if it doesn't see
them. I did this before and it worked great; I got everything that happened,
everything that errored and everything that should have happened, but
didn't.
FWIW, I am going to use the WITH TABLERESULTS. Dam the torpedoes and full
speed ahead!
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:uGar$xn5HHA.484@.TK2MSFTNGP06.phx.gbl...
>> I wanted to execute DBCC CHECKDB and add program logic to determine
>> success/failure as I recalled code that put DBCC results into a temp
>> table. Oops, no TABLERESULTS option. So, the messages are always
>> displayed and I can't get them into a data structure.
> Some DBCCs has TABLERESULTS even though it isn't documented. But I'm
> hesitant to recommend using that (if such exist on 2000 for DBCC CHECKDB)
> since if it isn't documented, then it isn't supported.
>
>> When I change the database name to something that doesn't exist, the
>> procedure aborts (is this what the OSQL was for?) and I never get to the
>> line 'PRINT @.@.ERROR'.
> Exception handling is a bit of a mess in TSQL. First, you have the engine
> behavior. Some errors will terminate the batch (procedure). Not much you
> can do if that happens.
> But, the Agent scheduler for TSQL jobsteps has some extra toppings where
> it terminates the job if any error with severity > 10 (as I remember it).
> This last thing is what I suggested OSQL for.
> Now, if you execute it from Query Analyzer and it terminates the batch,
> then OSQL won't help you. But I'm surprised. Try below. On my machine, the
> PRINT statement *is* executed. Do you see something different? Make sure
> you execute into text if you use Query Analyzer. Perhaps this is a change
> between 2000 and 2005?
> ALTER PROC p AS
> DBCC CHECKDB('ds') WITH TABLERESULTS
> PRINT 'Hello'
> GO
> EXEC p
> No SET option, I'm afraid. In the end, you migtht be better off using a
> client language (like VB.NET or C#.NET) for this, if you can't get the
> exception handling to your liking.
> As for the API to use, DMO is designed particularly for admin, but I'm not
> sure you can get to all the error messages that CHECKDB might return. At
> least this was the case when I used DMO many many years ago. If that is
> the case, consider ADO.NET which should have something like an error
> colection which you can loop through. Or whatever DB API you or some
> colleague of yours are most experienced in (ODBC etc).
> There are a couple of great error handling articles at
> http://www.sommarskog.se/.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:es7RLHn5HHA.5164@.TK2MSFTNGP05.phx.gbl...
>> Oh my, I hit a snag right out of the gate.
>> I wanted to execute DBCC CHECKDB and add program logic to determine
>> success/failure as I recalled code that put DBCC results into a temp
>> table. Oops, no TABLERESULTS option. So, the messages are always
>> displayed and I can't get them into a data structure.
>> When I change the database name to something that doesn't exist, the
>> procedure aborts (is this what the OSQL was for?) and I never get to the
>> line 'PRINT @.@.ERROR'.
>> I see the @.@.ERROR variable, but expected a SET option to change the
>> default behavior of immediately aborting - can't find anything.
>> Just a reminder: 2000.
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and find
>> ways to make it complain loudly is something unexpected/unwanted happens
>> (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6 months
>> ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB
>> encounters a corruption? Will it terminate the batch so nothing further
>> is executed? I can't answer that offhand, so thinking this through and
>> testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL
>> Server Agent is nice, but a TSQL job step will actually terminate the
>> execution on any error (as I recall it). So, you might want to schedule
>> a CmdExec job step instead and call OSQL.EXE for the execution of your
>> proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't
>> work for you use any of the options, possibly conditionally based on
>> for instance week day (like do full every Sunday). Btw, here's a
>> *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing
>> how much fragmentation really hurts you at the table/index level and
>> have conditional handling based on that, but that is probably overkill.
>> Same goes for the fillfactor value. You can't specify a fillfactor
>> value for INDEXDEFRAG, it will re-apply the value you specified when
>> you created the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does
>> not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL
>> Server *will update statistics by itself*, as they becomes stale. Now,
>> doing a manual update doesn't hurt, especially if you have the time to
>> use FULLSCAN (see UPDATE STATISTICS command). In most cases, this
>> database setting should be left to the default value. SQL Server uses a
>> value in sysindexes, rowmodctr (I believe) to determine how many
>> modifications and whether it is time to auto-update (when a plan is to
>> be re-used or generated). This is a rather big topic, so here comes
>> another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>> (there is one for 2000 as well, I don't have that URL handy, but this
>> is readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in
>> which you have a row for each database, and here you configure what
>> actions are to be performed. Then you loop that table instead of
>> sysdatabases. I'm not saying it is better, all depends on ones
>> particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL
>>I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be
>> run either before, or after the application maintenance (archiving,
>> credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options,
>> nothing is locked and on the dev server, it is taking about 2-3
>> minutes to complete. The only possible arguments I'm considering are
>> NOINDEX and WITH PHYSICAL_ONLY, but will probably go with no
>> arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since
>> the last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy
>> folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about
>> what level of locking it is using in 2000, but that should be
>> documented in the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available
>> on the MS web. It could be worth spending a few minutes with Google
>> to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance plans
>>> ... only there aren't any (including disk defrags)! Backups are done
>>> via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them
>>> running, but this is a 24x7x365 system and I'm not sure which of the
>>> jobs have the potential to lock a table, or an index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365
>>> system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>>> What's up with that? Do I just need to dig deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>
>>
>>
>>
>|||> FWIW, I am going to use the WITH TABLERESULTS. Dam the torpedoes and full speed ahead!
:-) Way to go!
(And at least you know you have unsupported code in there, in case something strange happens, which
I doubt...).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:%23WZin$n5HHA.2312@.TK2MSFTNGP06.phx.gbl...
>> ALTER PROC p AS
>> DBCC CHECKDB('ds') WITH TABLERESULTS
>> PRINT 'Hello'
>> GO
>> EXEC p
> "Hello" only prints on a 2005 engine, not on a 2000.
> Since the majority of the time everything will be fine, I'll let it fail and (if I can) get the
> engine to email me. Otherwise, I'll put something together that expects entries on success and
> will complain if it doesn't see them. I did this before and it worked great; I got everything that
> happened, everything that errored and everything that should have happened, but didn't.
> FWIW, I am going to use the WITH TABLERESULTS. Dam the torpedoes and full speed ahead!
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:uGar$xn5HHA.484@.TK2MSFTNGP06.phx.gbl...
>> I wanted to execute DBCC CHECKDB and add program logic to determine success/failure as I
>> recalled code that put DBCC results into a temp table. Oops, no TABLERESULTS option. So, the
>> messages are always displayed and I can't get them into a data structure.
>> Some DBCCs has TABLERESULTS even though it isn't documented. But I'm hesitant to recommend using
>> that (if such exist on 2000 for DBCC CHECKDB) since if it isn't documented, then it isn't
>> supported.
>>
>> When I change the database name to something that doesn't exist, the procedure aborts (is this
>> what the OSQL was for?) and I never get to the line 'PRINT @.@.ERROR'.
>> Exception handling is a bit of a mess in TSQL. First, you have the engine behavior. Some errors
>> will terminate the batch (procedure). Not much you can do if that happens.
>> But, the Agent scheduler for TSQL jobsteps has some extra toppings where it terminates the job if
>> any error with severity > 10 (as I remember it). This last thing is what I suggested OSQL for.
>> Now, if you execute it from Query Analyzer and it terminates the batch, then OSQL won't help you.
>> But I'm surprised. Try below. On my machine, the PRINT statement *is* executed. Do you see
>> something different? Make sure you execute into text if you use Query Analyzer. Perhaps this is a
>> change between 2000 and 2005?
>> ALTER PROC p AS
>> DBCC CHECKDB('ds') WITH TABLERESULTS
>> PRINT 'Hello'
>> GO
>> EXEC p
>> No SET option, I'm afraid. In the end, you migtht be better off using a client language (like
>> VB.NET or C#.NET) for this, if you can't get the exception handling to your liking.
>> As for the API to use, DMO is designed particularly for admin, but I'm not sure you can get to
>> all the error messages that CHECKDB might return. At least this was the case when I used DMO many
>> many years ago. If that is the case, consider ADO.NET which should have something like an error
>> colection which you can loop through. Or whatever DB API you or some colleague of yours are most
>> experienced in (ODBC etc).
>> There are a couple of great error handling articles at http://www.sommarskog.se/.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:es7RLHn5HHA.5164@.TK2MSFTNGP05.phx.gbl...
>> Oh my, I hit a snag right out of the gate.
>> I wanted to execute DBCC CHECKDB and add program logic to determine success/failure as I
>> recalled code that put DBCC results into a temp table. Oops, no TABLERESULTS option. So, the
>> messages are always displayed and I can't get them into a data structure.
>> When I change the database name to something that doesn't exist, the procedure aborts (is this
>> what the OSQL was for?) and I never get to the line 'PRINT @.@.ERROR'.
>> I see the @.@.ERROR variable, but expected a SET option to change the default behavior of
>> immediately aborting - can't find anything.
>> Just a reminder: 2000.
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully comprehending and following the
>> links.
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just
>> a different tune.
>> I write all production destined code with strong error checks and find ways to make it complain
>> loudly is something unexpected/unwanted happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all). I do remember a rather large discussion on this subject
>> from about 6 months ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will
>> it terminate the batch so nothing further is executed? I can't answer that offhand, so
>> thinking this through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to test this
>> realistically. I usually hack sysindexes (modify for instance the FirstIAM column for some row
>> to some rubbish value) - in a test database of course. You aren't allowed to update system
>> tables directly by default but read about sp_configure and you will probably figure out how to
>> do it (I don't want to post any more descriptive instructions considering this is a public
>> forum).
>> Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a
>> TSQL job step will actually terminate the execution on any error (as I recall it). So, you
>> might want to schedule a CmdExec job step instead and call OSQL.EXE for the execution of your
>> proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will
>> probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work for you use any of
>> the options, possibly conditionally based on for instance week day (like do full every
>> Sunday). Btw, here's a *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain)
>> run a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the
>> index (BOL says this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation
>> really hurts you at the table/index level and have conditional handling based on that, but
>> that is probably overkill. Same goes for the fillfactor value. You can't specify a fillfactor
>> value for INDEXDEFRAG, it will re-apply the value you specified when you created the index. If
>> you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also, be aware
>> of implications of defragging regarding transaction logging too (so you don't be surprised
>> that the following log backup is potentially huge). And read up on recovery models so you
>> understand all three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes
>> with the index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server *will update
>> statistics by itself*, as they becomes stale. Now, doing a manual update doesn't hurt,
>> especially if you have the time to use FULLSCAN (see UPDATE STATISTICS command). In most
>> cases, this database setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and whether it is time
>> to auto-update (when a plan is to be re-used or generated). This is a rather big topic, so
>> here comes another WP: http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>> (there is one for 2000 as well, I don't have that URL handy, but this is readable even if you
>> aren't on 2005).
>> Note that the auto-create statistics option isn't the same as auto-update. Auto-create means
>> that the optimizer will *create* statistics on non-indexed columns when it feels that such
>> statistics would be useful. Such statistics are also auto-updated by the engine by the same
>> handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which you have a row for
>> each database, and here you configure what actions are to be performed. Then you loop that
>> table instead of sysdatabases. I'm not saying it is better, all depends on ones particular
>> requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG,
>> STATS_DATE & UPDATE STATISTICS. It would be run either before, or after the application
>> maintenance (archiving, credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the Windows filesystem (and I
>> hope I can keep anything from Auto Growing too).
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you
>> don't specify any of the check options, nothing is locked and on the dev server, it is taking
>> about 2-3 minutes to complete. The only possible arguments I'm considering are NOINDEX and
>> WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain)
>> run a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the
>> index (BOL says this is an online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a
>> counter that measured insert/update activity since the last statistics update. Perhaps just
>> do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the database
>> prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>>> seen where maintenance is defined in 2005.
>>>
>>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on
>>> 2000, since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's
>>> under the legacy folder, quite simply?
>>>
>>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does
>>> it) will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm
>>> not sure about what level of locking it is using in 2000, but that should be documented in
>>> the 2000 Books Online).
>>>
>>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could
>>> be worth spending a few minutes with Google to try to dig it up...
>>>
>>> --
>>> Tibor Karaszi, SQL Server MVP
>>> http://www.karaszi.com/sqlserver/default.asp
>>> http://sqlblog.com/blogs/tibor_karaszi
>>>
>>>
>>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance plans ... only there aren't
>>> any (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them running, but this is a
>>> 24x7x365 system and I'm not sure which of the jobs have the potential to lock a table, or
>>> an index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>>> seen where maintenance is defined in 2005. What's up with that? Do I just need to dig
>>> deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>>
>>
>>
>>
>>
>|||The idea of performing CHECKTABLE on each table to spread the load out
across a week, month, or whatever was a compelling one, so I tried to run a
test.
Unfortunately, the list needs to be in a loop/cursor and I can't reset the
database inside a procedure (can I?)
DECLARE cTables CURSOR FOR
SELECT sc.name
FROM @.DB..sysobjects sc
WHERE xtype IN ('S', 'U')
Just plain doesn't work.
Is there a way to dynamically get the table names as I loop through the
databases?
"Jay" <nospam@.nospam.org> wrote in message
news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
> Well now. Just my first read took 10 minutes, never mind fully
> comprehending and following the links.
> Thank you very much for the time you spent on the reply Tibor and rest
> assured, the time a cat would spend picking apart a fish is nothing,
> compared to what I'm going to do with it.
> Just a couple comments for now:
> I grasp the topic well because I was an Informix DBA for 15 years and it's
> the same song, just a different tune.
> I write all production destined code with strong error checks and find
> ways to make it complain loudly is something unexpected/unwanted happens
> (plus a once a week ping).
> I chose INDEXDEFRAG because it is an online procedure and avoided
> DBREINDEX because it is an offline procedure (24x7 after all). I do
> remember a rather large discussion on this subject from about 6 months
> ago, but it doesn't really matter, because if I get any scheduled
> maintenance, it will be infrequent and limited.
> Thanks,
> Jay
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters
>> a corruption? Will it terminate the batch so nothing further is executed?
>> I can't answer that offhand, so thinking this through and testing is
>> important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server
>> Agent is nice, but a TSQL job step will actually terminate the execution
>> on any error (as I recall it). So, you might want to schedule a CmdExec
>> job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work
>> for you use any of the options, possibly conditionally based on for
>> instance week day (like do full every Sunday). Btw, here's a *great* blog
>> on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how
>> much fragmentation really hurts you at the table/index level and have
>> conditional handling based on that, but that is probably overkill. Same
>> goes for the fillfactor value. You can't specify a fillfactor value for
>> INDEXDEFRAG, it will re-apply the value you specified when you created
>> the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does not
>> happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server
>> *will update statistics by itself*, as they becomes stale. Now, doing a
>> manual update doesn't hurt, especially if you have the time to use
>> FULLSCAN (see UPDATE STATISTICS command). In most cases, this database
>> setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and
>> whether it is time to auto-update (when a plan is to be re-used or
>> generated). This is a rather big topic, so here comes another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there
>> is one for 2000 as well, I don't have that URL handy, but this is
>> readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which
>> you have a row for each database, and here you configure what actions are
>> to be performed. Then you loop that table instead of sysdatabases. I'm
>> not saying it is better, all depends on ones particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I
>>found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be run
>> either before, or after the application maintenance (archiving, credit
>> card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options, nothing
>> is locked and on the dev server, it is taking about 2-3 minutes to
>> complete. The only possible arguments I'm considering are NOINDEX and
>> WITH PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the
>> loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since the
>> last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy folder,
>> quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about what
>> level of locking it is using in 2000, but that should be documented in
>> the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on
>> the MS web. It could be worth spending a few minutes with Google to try
>> to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans
>> ... only there aren't any (including disk defrags)! Backups are done
>> via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them
>> running, but this is a 24x7x365 system and I'm not sure which of the
>> jobs have the potential to lock a table, or an index.
>> Advice, or links to docs that concern maintenance on a 24x7x365
>> system.
>> Also, in Management Studio the maintenance plans are under a Legacy
>> heading and I haven't seen where maintenance is defined in 2005.
>> What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>|||No, you would have to resort to dynamic SQL for that. A bit of a mess. Something like (to get you
rolling):
SET @.sql = 'DECLARE c CURSOR FOR
SELECT ...
FROM ' + @.db + '.dbo.sysobjects
WHERE '
EXEC @.sql
OPEN c
...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:OzvtLeo5HHA.2312@.TK2MSFTNGP06.phx.gbl...
> The idea of performing CHECKTABLE on each table to spread the load out across a week, month, or
> whatever was a compelling one, so I tried to run a test.
> Unfortunately, the list needs to be in a loop/cursor and I can't reset the database inside a
> procedure (can I?)
> DECLARE cTables CURSOR FOR
> SELECT sc.name
> FROM @.DB..sysobjects sc
> WHERE xtype IN ('S', 'U')
> Just plain doesn't work.
> Is there a way to dynamically get the table names as I loop through the databases?
>
> "Jay" <nospam@.nospam.org> wrote in message news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully comprehending and following the
>> links.
>> Thank you very much for the time you spent on the reply Tibor and rest assured, the time a cat
>> would spend picking apart a fish is nothing, compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and it's the same song, just a
>> different tune.
>> I write all production destined code with strong error checks and find ways to make it complain
>> loudly is something unexpected/unwanted happens (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided DBREINDEX because it is an
>> offline procedure (24x7 after all). I do remember a rather large discussion on this subject from
>> about 6 months ago, but it doesn't really matter, because if I get any scheduled maintenance, it
>> will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB encounters a corruption? Will it
>> terminate the batch so nothing further is executed? I can't answer that offhand, so thinking
>> this through and testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to test this realistically.
>> I usually hack sysindexes (modify for instance the FirstIAM column for some row to some rubbish
>> value) - in a test database of course. You aren't allowed to update system tables directly by
>> default but read about sp_configure and you will probably figure out how to do it (I don't want
>> to post any more descriptive instructions considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL Server Agent is nice, but a
>> TSQL job step will actually terminate the execution on any error (as I recall it). So, you might
>> want to schedule a CmdExec job step instead and call OSQL.EXE for the execution of your proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH PHYSICAL_ONLY, but will
>> probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't work for you use any of the
>> options, possibly conditionally based on for instance week day (like do full every Sunday). Btw,
>> here's a *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run
>> a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index
>> (BOL says this is an online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing how much fragmentation
>> really hurts you at the table/index level and have conditional handling based on that, but that
>> is probably overkill. Same goes for the fillfactor value. You can't specify a fillfactor value
>> for INDEXDEFRAG, it will re-apply the value you specified when you created the index. If you
>> want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx. Also, be aware of
>> implications of defragging regarding transaction logging too (so you don't be surprised that the
>> following log backup is potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the statistics that comes with
>> the index will also be rebuilt. This does not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL Server *will update
>> statistics by itself*, as they becomes stale. Now, doing a manual update doesn't hurt,
>> especially if you have the time to use FULLSCAN (see UPDATE STATISTICS command). In most cases,
>> this database setting should be left to the default value. SQL Server uses a value in
>> sysindexes, rowmodctr (I believe) to determine how many modifications and whether it is time to
>> auto-update (when a plan is to be re-used or generated). This is a rather big topic, so here
>> comes another WP: http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx (there is
>> one for 2000 as well, I don't have that URL handy, but this is readable even if you aren't on
>> 2005).
>> Note that the auto-create statistics option isn't the same as auto-update. Auto-create means
>> that the optimizer will *create* statistics on non-indexed columns when it feels that such
>> statistics would be useful. Such statistics are also auto-updated by the engine by the same
>> handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in which you have a row for
>> each database, and here you configure what actions are to be performed. Then you loop that table
>> instead of sysdatabases. I'm not saying it is better, all depends on ones particular
>> requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB, SHOWCONTIG, INDEXDEFRAG,
>> STATS_DATE & UPDATE STATISTICS. It would be run either before, or after the application
>> maintenance (archiving, credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the Windows filesystem (and I
>> hope I can keep anything from Auto Growing too).
>> Write a single stored procedure with an outer loop on DB's from master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases. According to BOL, if you don't
>> specify any of the check options, nothing is locked and on the dev server, it is taking about
>> 2-3 minutes to complete. The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit the loop and complain) run
>> a script based on the one in 2000 BOL (DBCC SHOWCONTIG) that does an INDEXDEFRAG on the index
>> (BOL says this is an online operation).
>> Last, run the SQL from BOL to loop on when statistics were last updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under Informix I had a counter
>> that measured insert/update activity since the last statistics update. Perhaps just do
>> everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the database
>> prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
>> news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>> SQL Server 2000
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>> seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no "new style" MP's on 2000,
>> since they didn't exist in ... 2000. So perhaps SSMS are showing 2000 (old style) MP's under
>> the legacy folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index (the way 2000 MP's does
>> it) will log the table during the index rebuild. Also, DBCC CHECKDB will use resources (I'm
>> not sure about what level of locking it is using in 2000, but that should be documented in the
>> 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available on the MS web. It could
>> be worth spending a few minutes with Google to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>> SQL Server 2000
>> I have finally been tasked and given access to the maintenance plans ... only there aren't
>> any (including disk defrags)! Backups are done via an SQLagent job, but that's it.
>> Normally I would just whomp the defaults together and start them running, but this is a
>> 24x7x365 system and I'm not sure which of the jobs have the potential to lock a table, or an
>> index.
>> Advice, or links to docs that concern maintenance on a 24x7x365 system.
>> Also, in Management Studio the maintenance plans are under a Legacy heading and I haven't
>> seen where maintenance is defined in 2005. What's up with that? Do I just need to dig deeper?
>> Thanks,
>> Jay
>>
>>
>>
>|||That is what I've been trying since my last post. I have (I've tried many
things as I go the the sp_executesql man page.
DECLARE @.ParmDefinition NVARCHAR(500)
DECLARE @.VarcharVar varchar(30)
DECLARE @.DBname varchar(30)
SET @.DBname=RTRIM(CONVERT(CHAR(30), @.DB))
PRINT 'DBname [' + @.DBname + ']'
SET @.SQL = N'DECLARE cTables CURSOR FOR
SELECT [name]
FROM @.DBname.dbo.sysobjects
WHERE xtype IN (''U'')'
SET @.ParmDefinition = N'@.DBname varchar'
PRINT '[' + RTRIM(@.SQL) + ']'
EXEC sp_executesql @.SQL, @.ParmDefinition, @.DBname = @.DB
and I get:
Server: Msg 170, Level 15, State 1, Line 3
Line 3: Incorrect syntax near '.'.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:eeBCuPp5HHA.5268@.TK2MSFTNGP02.phx.gbl...
> No, you would have to resort to dynamic SQL for that. A bit of a mess.
> Something like (to get you rolling):
> SET @.sql = 'DECLARE c CURSOR FOR
> SELECT ...
> FROM ' + @.db + '.dbo.sysobjects
> WHERE '
> EXEC @.sql
> OPEN c
> ...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:OzvtLeo5HHA.2312@.TK2MSFTNGP06.phx.gbl...
>> The idea of performing CHECKTABLE on each table to spread the load out
>> across a week, month, or whatever was a compelling one, so I tried to run
>> a test.
>> Unfortunately, the list needs to be in a loop/cursor and I can't reset
>> the database inside a procedure (can I?)
>> DECLARE cTables CURSOR FOR
>> SELECT sc.name
>> FROM @.DB..sysobjects sc
>> WHERE xtype IN ('S', 'U')
>> Just plain doesn't work.
>> Is there a way to dynamically get the table names as I loop through the
>> databases?
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and find
>> ways to make it complain loudly is something unexpected/unwanted happens
>> (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6 months
>> ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB
>> encounters a corruption? Will it terminate the batch so nothing further
>> is executed? I can't answer that offhand, so thinking this through and
>> testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL
>> Server Agent is nice, but a TSQL job step will actually terminate the
>> execution on any error (as I recall it). So, you might want to schedule
>> a CmdExec job step instead and call OSQL.EXE for the execution of your
>> proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't
>> work for you use any of the options, possibly conditionally based on
>> for instance week day (like do full every Sunday). Btw, here's a
>> *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing
>> how much fragmentation really hurts you at the table/index level and
>> have conditional handling based on that, but that is probably overkill.
>> Same goes for the fillfactor value. You can't specify a fillfactor
>> value for INDEXDEFRAG, it will re-apply the value you specified when
>> you created the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does
>> not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL
>> Server *will update statistics by itself*, as they becomes stale. Now,
>> doing a manual update doesn't hurt, especially if you have the time to
>> use FULLSCAN (see UPDATE STATISTICS command). In most cases, this
>> database setting should be left to the default value. SQL Server uses a
>> value in sysindexes, rowmodctr (I believe) to determine how many
>> modifications and whether it is time to auto-update (when a plan is to
>> be re-used or generated). This is a rather big topic, so here comes
>> another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>> (there is one for 2000 as well, I don't have that URL handy, but this
>> is readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in
>> which you have a row for each database, and here you configure what
>> actions are to be performed. Then you loop that table instead of
>> sysdatabases. I'm not saying it is better, all depends on ones
>> particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL
>>I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be
>> run either before, or after the application maintenance (archiving,
>> credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options,
>> nothing is locked and on the dev server, it is taking about 2-3
>> minutes to complete. The only possible arguments I'm considering are
>> NOINDEX and WITH PHYSICAL_ONLY, but will probably go with no
>> arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since
>> the last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy
>> folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about
>> what level of locking it is using in 2000, but that should be
>> documented in the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available
>> on the MS web. It could be worth spending a few minutes with Google
>> to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance plans
>>> ... only there aren't any (including disk defrags)! Backups are done
>>> via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them
>>> running, but this is a 24x7x365 system and I'm not sure which of the
>>> jobs have the potential to lock a table, or an index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365
>>> system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>>> What's up with that? Do I just need to dig deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>
>>
>>
>>
>|||SET @.SQL = N'DECLARE cTables CURSOR FOR
SELECT [name]
FROM @.DBname.dbo.sysobjects
WHERE xtype IN (''U'')'
SET @.ParmDefinition = N'@.DBname varchar'
PRINT '[' + RTRIM(@.SQL) + ']'
EXEC @.SQL
Server: Msg 203, Level 16, State 2, Procedure mDBMaintenance, Line 65
The name 'DECLARE cTables CURSOR FOR
SELECT [name]
FROM @.DBname.dbo.sysobjects
WHERE xtype IN ('U')' is not a valid identifier.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:eeBCuPp5HHA.5268@.TK2MSFTNGP02.phx.gbl...
> No, you would have to resort to dynamic SQL for that. A bit of a mess.
> Something like (to get you rolling):
> SET @.sql = 'DECLARE c CURSOR FOR
> SELECT ...
> FROM ' + @.db + '.dbo.sysobjects
> WHERE '
> EXEC @.sql
> OPEN c
> ...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:OzvtLeo5HHA.2312@.TK2MSFTNGP06.phx.gbl...
>> The idea of performing CHECKTABLE on each table to spread the load out
>> across a week, month, or whatever was a compelling one, so I tried to run
>> a test.
>> Unfortunately, the list needs to be in a loop/cursor and I can't reset
>> the database inside a procedure (can I?)
>> DECLARE cTables CURSOR FOR
>> SELECT sc.name
>> FROM @.DB..sysobjects sc
>> WHERE xtype IN ('S', 'U')
>> Just plain doesn't work.
>> Is there a way to dynamically get the table names as I loop through the
>> databases?
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%236s9kxb5HHA.2752@.TK2MSFTNGP06.phx.gbl...
>> Well now. Just my first read took 10 minutes, never mind fully
>> comprehending and following the links.
>> Thank you very much for the time you spent on the reply Tibor and rest
>> assured, the time a cat would spend picking apart a fish is nothing,
>> compared to what I'm going to do with it.
>> Just a couple comments for now:
>> I grasp the topic well because I was an Informix DBA for 15 years and
>> it's the same song, just a different tune.
>> I write all production destined code with strong error checks and find
>> ways to make it complain loudly is something unexpected/unwanted happens
>> (plus a once a week ping).
>> I chose INDEXDEFRAG because it is an online procedure and avoided
>> DBREINDEX because it is an offline procedure (24x7 after all). I do
>> remember a rather large discussion on this subject from about 6 months
>> ago, but it doesn't really matter, because if I get any scheduled
>> maintenance, it will be infrequent and limited.
>> Thanks,
>> Jay
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote
>> in message news:%23HYDpSb5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> It certainly seems you grasp the topic well. Some comments:
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Watch out for exceptions. What happens if for instance CHECKDB
>> encounters a corruption? Will it terminate the batch so nothing further
>> is executed? I can't answer that offhand, so thinking this through and
>> testing is important.
>> You might want to deliberately crash a database so that CHEDB fails to
>> test this realistically. I usually hack sysindexes (modify for instance
>> the FirstIAM column for some row to some rubbish value) - in a test
>> database of course. You aren't allowed to update system tables directly
>> by default but read about sp_configure and you will probably figure out
>> how to do it (I don't want to post any more descriptive instructions
>> considering this is a public forum).
>> Also, consider the client application handling of exceptions. SQL
>> Server Agent is nice, but a TSQL job step will actually terminate the
>> execution on any error (as I recall it). So, you might want to schedule
>> a CmdExec job step instead and call OSQL.EXE for the execution of your
>> proc.
>>
>> The only possible arguments I'm considering are NOINDEX and WITH
>> PHYSICAL_ONLY, but will probably go with no arguments.
>> Yes, go with as complete check as you can live with. If that doesn't
>> work for you use any of the options, possibly conditionally based on
>> for instance week day (like do full every Sunday). Btw, here's a
>> *great* blog on CHECKDB and related topics:
>> http://blogs.msdn.com/sqlserverstorageengine/default.aspx
>>
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Yep, sounds fine. I guess you could spend lots of time with analyzing
>> how much fragmentation really hurts you at the table/index level and
>> have conditional handling based on that, but that is probably overkill.
>> Same goes for the fillfactor value. You can't specify a fillfactor
>> value for INDEXDEFRAG, it will re-apply the value you specified when
>> you created the index. If you want to read up on this topic, check out
>> http://www.microsoft.com/technet/prodtechnol/sql/2000/maintain/ss2kidbp.mspx.
>> Also, be aware of implications of defragging regarding transaction
>> logging too (so you don't be surprised that the following log backup is
>> potentially huge). And read up on recovery models so you understand all
>> three.
>>
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> and update any old statistics.
>> First, be aware that if you rebuild (DBREINDEX) your indexes then the
>> statistics that comes with the index will also be rebuilt. This does
>> not happen if you INDEXDEFRAG, though.
>> Also, the database setting "auto update statistics" means that SQL
>> Server *will update statistics by itself*, as they becomes stale. Now,
>> doing a manual update doesn't hurt, especially if you have the time to
>> use FULLSCAN (see UPDATE STATISTICS command). In most cases, this
>> database setting should be left to the default value. SQL Server uses a
>> value in sysindexes, rowmodctr (I believe) to determine how many
>> modifications and whether it is time to auto-update (when a plan is to
>> be re-used or generated). This is a rather big topic, so here comes
>> another WP:
>> http://www.microsoft.com/technet/prodtechnol/sql/2005/recomp.mspx
>> (there is one for 2000 as well, I don't have that URL handy, but this
>> is readable even if you aren't on 2005).
>> Note that the auto-create statistics option isn't the same as
>> auto-update. Auto-create means that the optimizer will *create*
>> statistics on non-indexed columns when it feels that such statistics
>> would be useful. Such statistics are also auto-updated by the engine by
>> the same handling as described above (the auto-update setting).
>> Finally, instead of having this loop, consider creating a table, in
>> which you have a row for each database, and here you configure what
>> actions are to be performed. Then you loop that table instead of
>> sysdatabases. I'm not saying it is better, all depends on ones
>> particular requirements etc.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ubj7n7a5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>I wasn't able to find much with an internet search, but digging in BOL
>>I found a lot.
>> Is this a good plan for 24x7 SQL Server 2000 maintenance (excluding
>> backup)?
>> Am I missing anything?
>> Am I doing more than is needed?
>> Did I miss something in BOL that makes this plan risky?
>> Here is my intended plan: write a procedure that uses CHECKDB,
>> SHOWCONTIG, INDEXDEFRAG, STATS_DATE & UPDATE STATISTICS. It would be
>> run either before, or after the application maintenance (archiving,
>> credit card batches, search engine data dumps, etc).
>> At no time will I allow an automated program shrink anything in the
>> Windows filesystem (and I hope I can keep anything from Auto Growing
>> too).
>> Write a single stored procedure with an outer loop on DB's from
>> master..sysdatabases
>> Start with DBCC CHECKDB('dbname') looping through all databases.
>> According to BOL, if you don't specify any of the check options,
>> nothing is locked and on the dev server, it is taking about 2-3
>> minutes to complete. The only possible arguments I'm considering are
>> NOINDEX and WITH PHYSICAL_ONLY, but will probably go with no
>> arguments.
>> Within the loop, after a success on the CHECKDB (failure would exit
>> the loop and complain) run a script based on the one in 2000 BOL (DBCC
>> SHOWCONTIG) that does an INDEXDEFRAG on the index (BOL says this is an
>> online operation).
>> Last, run the SQL from BOL to loop on when statistics were last
>> updated:
>> SELECT 'Index Name' = i.name,
>> 'Statistics Date' = STATS_DATE(i.id, i.indid)
>> FROM sysobjects o, sysindexes i
>> WHERE o.name = '_table_name_'
>> AND o.id = i.id
>> and update any old statistics.
>> Done.
>> Now, I'm not really sure how to decide what statistics are old. Under
>> Informix I had a counter that measured insert/update activity since
>> the last statistics update. Perhaps just do everything nightly?
>> I'm also not sure how the "Auto Create Statistics" checkbox on the
>> database prosperities/options tab interacts with update statistics.
>> Thanks,
>> Jay
>>
>>
>> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com>
>> wrote in message news:OmJUAXY5HHA.4712@.TK2MSFTNGP04.phx.gbl...
>>> SQL Server 2000
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>> Seems you are using SSMS to connect to a 2000 instance. There are no
>> "new style" MP's on 2000, since they didn't exist in ... 2000. So
>> perhaps SSMS are showing 2000 (old style) MP's under the legacy
>> folder, quite simply?
>> Be care full especially with rebuilding indexes. Rebuilding an index
>> (the way 2000 MP's does it) will log the table during the index
>> rebuild. Also, DBCC CHECKDB will use resources (I'm not sure about
>> what level of locking it is using in 2000, but that should be
>> documented in the 2000 Books Online).
>> I believe that there's an "Operational Guideline" for 2000 available
>> on the MS web. It could be worth spending a few minutes with Google
>> to try to dig it up...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:%23kB0DrQ5HHA.3900@.TK2MSFTNGP02.phx.gbl...
>>> SQL Server 2000
>>>
>>> I have finally been tasked and given access to the maintenance plans
>>> ... only there aren't any (including disk defrags)! Backups are done
>>> via an SQLagent job, but that's it.
>>>
>>> Normally I would just whomp the defaults together and start them
>>> running, but this is a 24x7x365 system and I'm not sure which of the
>>> jobs have the potential to lock a table, or an index.
>>>
>>> Advice, or links to docs that concern maintenance on a 24x7x365
>>> system.
>>>
>>> Also, in Management Studio the maintenance plans are under a Legacy
>>> heading and I haven't seen where maintenance is defined in 2005.
>>> What's up with that? Do I just need to dig deeper?
>>>
>>> Thanks,
>>> Jay
>>>
>>
>>
>>
>>
>|||declare @.sql nvarchar(4000)
declare @.db char(6)
set @.db = 'master'
SET @.sql = '
DECLARE c CURSOR FOR
SELECT name
FROM ' + @.db + '.dbo.sysobjects
WHERE xtype = ''S''
'
EXEC @.sql
--OPEN c
(as close as I can get you example to code that will work for everyone)
returns:
Server: Msg 911, Level 16, State 1, Line 11
Could not locate entry in sysdatabases for database '
DECLARE c CURSOR FOR
SELECT name
FROM master'. No entry found with that name. Make sure that the name is
entered correctly.|||Wait, the following seems to work.
--
declare @.sql nvarchar(4000)
declare @.db varchar(60)
declare @.table sysname
set @.db = 'master'
SET @.sql = '
DECLARE c CURSOR FOR
SELECT name
FROM ' + @.db + '.dbo.sysobjects
WHERE xtype = ''U''
'
PRINT '[' + @.sql + ']'
EXEC sp_executesql @.sql
OPEN c
fetch from c into @.table
while (@.@.fetch_status = 0)
begin
print @.table
fetch from c into @.table
end
CLOSE c
DEALLOCATE c
--
"Jay" <nospam@.nospam.org> wrote in message
news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
> declare @.sql nvarchar(4000)
> declare @.db char(6)
> set @.db = 'master'
> SET @.sql = '
> DECLARE c CURSOR FOR
> SELECT name
> FROM ' + @.db + '.dbo.sysobjects
> WHERE xtype = ''S''
> '
> EXEC @.sql
> --OPEN c
> (as close as I can get you example to code that will work for everyone)
> returns:
> Server: Msg 911, Level 16, State 1, Line 11
> Could not locate entry in sysdatabases for database '
> DECLARE c CURSOR FOR
> SELECT name
> FROM master'. No entry found with that name. Make sure that the name is
> entered correctly.
>|||OK, this defiantly works, though I could have sworn I tried this. Guess the
frustration is getting to me a little.
Thank you Tibor.
declare @.sql nvarchar(4000)
declare @.db varchar(60)
declare @.table sysname
--set @.db = 'master'
declare cDB cursor for
SELECT name from master..sysdatabases sdb
WHERE sdb.name NOT IN ('tempdb')
open cDB
fetch cDB into @.db
while (@.@.fetch_status = 0)
begin
PRINT ''
PRINT ''
PRINT '=========>> ' + @.DB
SET @.sql = '
DECLARE c CURSOR FOR
SELECT name
FROM ' + @.db + '.dbo.sysobjects
WHERE xtype = ''U''
'
-- PRINT '[' + @.sql + ']'
EXEC sp_executesql @.sql
OPEN c
fetch from c into @.table
while (@.@.fetch_status = 0)
begin
print @.table
fetch from c into @.table
end
CLOSE c
DEALLOCATE c
fetch cDB into @.db
end
close cDB
deallocate cDB
"Jay" <nospam@.nospam.org> wrote in message
news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
> declare @.sql nvarchar(4000)
> declare @.db char(6)
> set @.db = 'master'
> SET @.sql = '
> DECLARE c CURSOR FOR
> SELECT name
> FROM ' + @.db + '.dbo.sysobjects
> WHERE xtype = ''S''
> '
> EXEC @.sql
> --OPEN c
> (as close as I can get you example to code that will work for everyone)
> returns:
> Server: Msg 911, Level 16, State 1, Line 11
> Could not locate entry in sysdatabases for database '
> DECLARE c CURSOR FOR
> SELECT name
> FROM master'. No entry found with that name. Make sure that the name is
> entered correctly.
>|||Getting there. There's just one more thing I recommend, for robustness. If you execute below and
then run your cursor you will understand:
CREATE DATABASE "my database"
So, you can have databases and tables with names that aren't standard identifiers. I recommend you
cater for that in your cursor code. A couple of ways to do that:
SELECT '"' + name + '"' from master..sysdatabases sdb
or
SELECT QUOTENAME(name) from master..sysdatabases sdb
If you don't want to do it in the SELECT which retreives the name of the database, you can of course
do it like below instead:
SET @.sql = '
DECLARE c CURSOR FOR
SELECT name
FROM ' + QUOTENAME(@.db) + '.dbo.sysobjects
WHERE xtype = ''U''
'
In SQL Server you can surround an object name (identifier) with either double-quotes (ANSI SQL
standard) or square bracket. Many SQL Server preople prefer square brackets, I prefer double quotes.
Doesn't really matter.
Also, QUOTENAME is a little bit more robust, since it will (should) handle if you have a database
named something like my"Data[base], which just slapping double quotes or square brackets around
doesn't handle. Not likely that you have that extremely strange names, of course.
And, of course, you should do the same for the inner cursor, where you pick up the table name
(depending on how you are going to use it).
Also, you might want to expand the table name to include the object owner, again, depending on how
you are going to use it. If you have for instance pete.customers, then doing something like DBCC
DBREINDEX('customers') will probably refer to dbo.customers, and either do the wrong table or fail.
You can for instance join sysobjects to sysusers.
However, if you base index defrag on output from DBCC SHOWCONTIG, I don't think you have to worry
about it, but it was a while since I read that code snippet in Books Online. Just one more thing to
think of...
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"Jay" <nospam@.nospam.org> wrote in message news:ulDpYjp5HHA.3940@.TK2MSFTNGP05.phx.gbl...
> OK, this defiantly works, though I could have sworn I tried this. Guess the frustration is getting
> to me a little.
> Thank you Tibor.
> declare @.sql nvarchar(4000)
> declare @.db varchar(60)
> declare @.table sysname
> --set @.db = 'master'
> declare cDB cursor for
> SELECT name from master..sysdatabases sdb
> WHERE sdb.name NOT IN ('tempdb')
> open cDB
> fetch cDB into @.db
> while (@.@.fetch_status = 0)
> begin
> PRINT ''
> PRINT ''
> PRINT '=========>> ' + @.DB
> SET @.sql = '
> DECLARE c CURSOR FOR
> SELECT name
> FROM ' + @.db + '.dbo.sysobjects
> WHERE xtype = ''U''
> '
> -- PRINT '[' + @.sql + ']'
> EXEC sp_executesql @.sql
> OPEN c
> fetch from c into @.table
> while (@.@.fetch_status = 0)
> begin
> print @.table
> fetch from c into @.table
> end
> CLOSE c
> DEALLOCATE c
> fetch cDB into @.db
> end
> close cDB
> deallocate cDB
> "Jay" <nospam@.nospam.org> wrote in message news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
>> declare @.sql nvarchar(4000)
>> declare @.db char(6)
>> set @.db = 'master'
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''S''
>> '
>> EXEC @.sql
>> --OPEN c
>> (as close as I can get you example to code that will work for everyone)
>> returns:
>> Server: Msg 911, Level 16, State 1, Line 11
>> Could not locate entry in sysdatabases for database '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM master'. No entry found with that name. Make sure that the name is entered correctly.
>>
>|||I had already changed the table level code to include the owner, so ya,
putting on the DB make all the sense in the world, thanks.
As to the QUOTENAME, I debated a little what to do, as I was already quoting
on the use of the variables. However, I think I like it as it provides some
cheap insurance and cleans up the code a touch. As to the problem with
spaces in an object name, I'm well aware of that issue and it was one of the
things I really hate about Windows.
The lack of the fully qualified names was never intended to be left. It goes
to how I code something when I don't really know what I'm dealing with. I
try to keep things as simple as possible. However, I always make several
cleanup passes and fully qualify anything I'm referencing before anyone else
knows I'm close to finished (with the exception of a programmer who
understands).
And shame, shame shame on you for even the slightest suggestion that
DBREINDEX would be used in an automated nightly program running on a 24x7
system :)
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:usHxQuu5HHA.5184@.TK2MSFTNGP03.phx.gbl...
> Getting there. There's just one more thing I recommend, for robustness. If
> you execute below and then run your cursor you will understand:
> CREATE DATABASE "my database"
> So, you can have databases and tables with names that aren't standard
> identifiers. I recommend you cater for that in your cursor code. A couple
> of ways to do that:
> SELECT '"' + name + '"' from master..sysdatabases sdb
> or
> SELECT QUOTENAME(name) from master..sysdatabases sdb
> If you don't want to do it in the SELECT which retreives the name of the
> database, you can of course do it like below instead:
> SET @.sql = '
> DECLARE c CURSOR FOR
> SELECT name
> FROM ' + QUOTENAME(@.db) + '.dbo.sysobjects
> WHERE xtype = ''U''
> '
> In SQL Server you can surround an object name (identifier) with either
> double-quotes (ANSI SQL standard) or square bracket. Many SQL Server
> preople prefer square brackets, I prefer double quotes. Doesn't really
> matter.
> Also, QUOTENAME is a little bit more robust, since it will (should) handle
> if you have a database named something like my"Data[base], which just
> slapping double quotes or square brackets around doesn't handle. Not
> likely that you have that extremely strange names, of course.
> And, of course, you should do the same for the inner cursor, where you
> pick up the table name (depending on how you are going to use it).
> Also, you might want to expand the table name to include the object owner,
> again, depending on how you are going to use it. If you have for instance
> pete.customers, then doing something like DBCC DBREINDEX('customers') will
> probably refer to dbo.customers, and either do the wrong table or fail.
> You can for instance join sysobjects to sysusers.
> However, if you base index defrag on output from DBCC SHOWCONTIG, I don't
> think you have to worry about it, but it was a while since I read that
> code snippet in Books Online. Just one more thing to think of...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:ulDpYjp5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> OK, this defiantly works, though I could have sworn I tried this. Guess
>> the frustration is getting to me a little.
>> Thank you Tibor.
>> declare @.sql nvarchar(4000)
>> declare @.db varchar(60)
>> declare @.table sysname
>> --set @.db = 'master'
>> declare cDB cursor for
>> SELECT name from master..sysdatabases sdb
>> WHERE sdb.name NOT IN ('tempdb')
>> open cDB
>> fetch cDB into @.db
>> while (@.@.fetch_status = 0)
>> begin
>> PRINT ''
>> PRINT ''
>> PRINT '=========>> ' + @.DB
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''U''
>> '
>> -- PRINT '[' + @.sql + ']'
>> EXEC sp_executesql @.sql
>> OPEN c
>> fetch from c into @.table
>> while (@.@.fetch_status = 0)
>> begin
>> print @.table
>> fetch from c into @.table
>> end
>> CLOSE c
>> DEALLOCATE c
>> fetch cDB into @.db
>> end
>> close cDB
>> deallocate cDB
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
>> declare @.sql nvarchar(4000)
>> declare @.db char(6)
>> set @.db = 'master'
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''S''
>> '
>> EXEC @.sql
>> --OPEN c
>> (as close as I can get you example to code that will work for everyone)
>> returns:
>> Server: Msg 911, Level 16, State 1, Line 11
>> Could not locate entry in sysdatabases for database '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM master'. No entry found with that name. Make sure that the name is
>> entered correctly.
>>
>>
>|||A curosity.
DBCC CHECKCATALOG and DBCC CHECKALLOC seem to refuse an owner name and will
only accept a database name.
DBCC CHECKALLOC('model.dbo') & DBCC CHECKALLOC('dbo.model') both fail
complaining that it can't find the database, while DBCC CHECKALLOC('model')
works fine.
I did this on 2005 Express, which is what I have at home.
So, I guess pulling the database owner is pointless - pulling the table
owner is still usefull.
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:usHxQuu5HHA.5184@.TK2MSFTNGP03.phx.gbl...
> Getting there. There's just one more thing I recommend, for robustness. If
> you execute below and then run your cursor you will understand:
> CREATE DATABASE "my database"
> So, you can have databases and tables with names that aren't standard
> identifiers. I recommend you cater for that in your cursor code. A couple
> of ways to do that:
> SELECT '"' + name + '"' from master..sysdatabases sdb
> or
> SELECT QUOTENAME(name) from master..sysdatabases sdb
> If you don't want to do it in the SELECT which retreives the name of the
> database, you can of course do it like below instead:
> SET @.sql = '
> DECLARE c CURSOR FOR
> SELECT name
> FROM ' + QUOTENAME(@.db) + '.dbo.sysobjects
> WHERE xtype = ''U''
> '
> In SQL Server you can surround an object name (identifier) with either
> double-quotes (ANSI SQL standard) or square bracket. Many SQL Server
> preople prefer square brackets, I prefer double quotes. Doesn't really
> matter.
> Also, QUOTENAME is a little bit more robust, since it will (should) handle
> if you have a database named something like my"Data[base], which just
> slapping double quotes or square brackets around doesn't handle. Not
> likely that you have that extremely strange names, of course.
> And, of course, you should do the same for the inner cursor, where you
> pick up the table name (depending on how you are going to use it).
> Also, you might want to expand the table name to include the object owner,
> again, depending on how you are going to use it. If you have for instance
> pete.customers, then doing something like DBCC DBREINDEX('customers') will
> probably refer to dbo.customers, and either do the wrong table or fail.
> You can for instance join sysobjects to sysusers.
> However, if you base index defrag on output from DBCC SHOWCONTIG, I don't
> think you have to worry about it, but it was a while since I read that
> code snippet in Books Online. Just one more thing to think of...
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://sqlblog.com/blogs/tibor_karaszi
>
> "Jay" <nospam@.nospam.org> wrote in message
> news:ulDpYjp5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> OK, this defiantly works, though I could have sworn I tried this. Guess
>> the frustration is getting to me a little.
>> Thank you Tibor.
>> declare @.sql nvarchar(4000)
>> declare @.db varchar(60)
>> declare @.table sysname
>> --set @.db = 'master'
>> declare cDB cursor for
>> SELECT name from master..sysdatabases sdb
>> WHERE sdb.name NOT IN ('tempdb')
>> open cDB
>> fetch cDB into @.db
>> while (@.@.fetch_status = 0)
>> begin
>> PRINT ''
>> PRINT ''
>> PRINT '=========>> ' + @.DB
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''U''
>> '
>> -- PRINT '[' + @.sql + ']'
>> EXEC sp_executesql @.sql
>> OPEN c
>> fetch from c into @.table
>> while (@.@.fetch_status = 0)
>> begin
>> print @.table
>> fetch from c into @.table
>> end
>> CLOSE c
>> DEALLOCATE c
>> fetch cDB into @.db
>> end
>> close cDB
>> deallocate cDB
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
>> declare @.sql nvarchar(4000)
>> declare @.db char(6)
>> set @.db = 'master'
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''S''
>> '
>> EXEC @.sql
>> --OPEN c
>> (as close as I can get you example to code that will work for everyone)
>> returns:
>> Server: Msg 911, Level 16, State 1, Line 11
>> Could not locate entry in sysdatabases for database '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM master'. No entry found with that name. Make sure that the name is
>> entered correctly.
>>
>>
>|||> And shame, shame shame on you for even the slightest suggestion that
> DBREINDEX would be used in an automated nightly program running on a 24x7
> system :)
Down, boy, down. That was just an example of a command... ;-)
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"JayKon" <spam@.nospam.org> wrote in message news:eF0u1Iy5HHA.980@.TK2MSFTNGP06.phx.gbl...
>I had already changed the table level code to include the owner, so ya,
> putting on the DB make all the sense in the world, thanks.
> As to the QUOTENAME, I debated a little what to do, as I was already quoting
> on the use of the variables. However, I think I like it as it provides some
> cheap insurance and cleans up the code a touch. As to the problem with
> spaces in an object name, I'm well aware of that issue and it was one of the
> things I really hate about Windows.
> The lack of the fully qualified names was never intended to be left. It goes
> to how I code something when I don't really know what I'm dealing with. I
> try to keep things as simple as possible. However, I always make several
> cleanup passes and fully qualify anything I'm referencing before anyone else
> knows I'm close to finished (with the exception of a programmer who
> understands).
> And shame, shame shame on you for even the slightest suggestion that
> DBREINDEX would be used in an automated nightly program running on a 24x7
> system :)
>
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:usHxQuu5HHA.5184@.TK2MSFTNGP03.phx.gbl...
>> Getting there. There's just one more thing I recommend, for robustness. If
>> you execute below and then run your cursor you will understand:
>> CREATE DATABASE "my database"
>> So, you can have databases and tables with names that aren't standard
>> identifiers. I recommend you cater for that in your cursor code. A couple
>> of ways to do that:
>> SELECT '"' + name + '"' from master..sysdatabases sdb
>> or
>> SELECT QUOTENAME(name) from master..sysdatabases sdb
>> If you don't want to do it in the SELECT which retreives the name of the
>> database, you can of course do it like below instead:
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + QUOTENAME(@.db) + '.dbo.sysobjects
>> WHERE xtype = ''U''
>> '
>> In SQL Server you can surround an object name (identifier) with either
>> double-quotes (ANSI SQL standard) or square bracket. Many SQL Server
>> preople prefer square brackets, I prefer double quotes. Doesn't really
>> matter.
>> Also, QUOTENAME is a little bit more robust, since it will (should) handle
>> if you have a database named something like my"Data[base], which just
>> slapping double quotes or square brackets around doesn't handle. Not
>> likely that you have that extremely strange names, of course.
>> And, of course, you should do the same for the inner cursor, where you
>> pick up the table name (depending on how you are going to use it).
>> Also, you might want to expand the table name to include the object owner,
>> again, depending on how you are going to use it. If you have for instance
>> pete.customers, then doing something like DBCC DBREINDEX('customers') will
>> probably refer to dbo.customers, and either do the wrong table or fail.
>> You can for instance join sysobjects to sysusers.
>> However, if you base index defrag on output from DBCC SHOWCONTIG, I don't
>> think you have to worry about it, but it was a while since I read that
>> code snippet in Books Online. Just one more thing to think of...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:ulDpYjp5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> OK, this defiantly works, though I could have sworn I tried this. Guess
>> the frustration is getting to me a little.
>> Thank you Tibor.
>> declare @.sql nvarchar(4000)
>> declare @.db varchar(60)
>> declare @.table sysname
>> --set @.db = 'master'
>> declare cDB cursor for
>> SELECT name from master..sysdatabases sdb
>> WHERE sdb.name NOT IN ('tempdb')
>> open cDB
>> fetch cDB into @.db
>> while (@.@.fetch_status = 0)
>> begin
>> PRINT ''
>> PRINT ''
>> PRINT '=========>> ' + @.DB
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''U''
>> '
>> -- PRINT '[' + @.sql + ']'
>> EXEC sp_executesql @.sql
>> OPEN c
>> fetch from c into @.table
>> while (@.@.fetch_status = 0)
>> begin
>> print @.table
>> fetch from c into @.table
>> end
>> CLOSE c
>> DEALLOCATE c
>> fetch cDB into @.db
>> end
>> close cDB
>> deallocate cDB
>> "Jay" <nospam@.nospam.org> wrote in message
>> news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
>> declare @.sql nvarchar(4000)
>> declare @.db char(6)
>> set @.db = 'master'
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''S''
>> '
>> EXEC @.sql
>> --OPEN c
>> (as close as I can get you example to code that will work for everyone)
>> returns:
>> Server: Msg 911, Level 16, State 1, Line 11
>> Could not locate entry in sysdatabases for database '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM master'. No entry found with that name. Make sure that the name is
>> entered correctly.
>>
>>
>|||> DBCC CHECKALLOC('model.dbo') & DBCC CHECKALLOC('dbo.model') both fail
<snip>
> So, I guess pulling the database owner is pointless - pulling the table owner is still usefull.
Hmm, a database doesn't have an owner in that sense. Well..., it has an owner. A login owns a
database and that login is the user dbo in the database. But a database doesn't have an owner seen
from a name resolution standpoint.
Since the owner of the database is always the user dbo, you would always have pubs.dbo and
Northwind.dbo, you couldn't have *anything else* but .dbo. One could argue that we would use
dbname.loginname instead of dbname.username, of course. But basically the purpose of a namespace is
to keep names unique, so having any type of owner in the db name doesn't add anything, since the db
name alone need to be unique in SQL Server. You cannot have two logins each owning a database of the
same name (i.e., we cannot have JayKon.pubs and Tibor.pubs or something like that). So whenever you
see "database name", it is always *only* the database name (like pubs).
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi
"JayKon" <spam@.nospam.org> wrote in message news:OzpC2jy5HHA.600@.TK2MSFTNGP05.phx.gbl...
>A curosity.
> DBCC CHECKCATALOG and DBCC CHECKALLOC seem to refuse an owner name and will only accept a database
> name.
> DBCC CHECKALLOC('model.dbo') & DBCC CHECKALLOC('dbo.model') both fail complaining that it can't
> find the database, while DBCC CHECKALLOC('model') works fine.
> I did this on 2005 Express, which is what I have at home.
> So, I guess pulling the database owner is pointless - pulling the table owner is still usefull.
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in message
> news:usHxQuu5HHA.5184@.TK2MSFTNGP03.phx.gbl...
>> Getting there. There's just one more thing I recommend, for robustness. If you execute below and
>> then run your cursor you will understand:
>> CREATE DATABASE "my database"
>> So, you can have databases and tables with names that aren't standard identifiers. I recommend
>> you cater for that in your cursor code. A couple of ways to do that:
>> SELECT '"' + name + '"' from master..sysdatabases sdb
>> or
>> SELECT QUOTENAME(name) from master..sysdatabases sdb
>> If you don't want to do it in the SELECT which retreives the name of the database, you can of
>> course do it like below instead:
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + QUOTENAME(@.db) + '.dbo.sysobjects
>> WHERE xtype = ''U''
>> '
>> In SQL Server you can surround an object name (identifier) with either double-quotes (ANSI SQL
>> standard) or square bracket. Many SQL Server preople prefer square brackets, I prefer double
>> quotes. Doesn't really matter.
>> Also, QUOTENAME is a little bit more robust, since it will (should) handle if you have a database
>> named something like my"Data[base], which just slapping double quotes or square brackets around
>> doesn't handle. Not likely that you have that extremely strange names, of course.
>> And, of course, you should do the same for the inner cursor, where you pick up the table name
>> (depending on how you are going to use it).
>> Also, you might want to expand the table name to include the object owner, again, depending on
>> how you are going to use it. If you have for instance pete.customers, then doing something like
>> DBCC DBREINDEX('customers') will probably refer to dbo.customers, and either do the wrong table
>> or fail. You can for instance join sysobjects to sysusers.
>> However, if you base index defrag on output from DBCC SHOWCONTIG, I don't think you have to worry
>> about it, but it was a while since I read that code snippet in Books Online. Just one more thing
>> to think of...
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://sqlblog.com/blogs/tibor_karaszi
>>
>> "Jay" <nospam@.nospam.org> wrote in message news:ulDpYjp5HHA.3940@.TK2MSFTNGP05.phx.gbl...
>> OK, this defiantly works, though I could have sworn I tried this. Guess the frustration is
>> getting to me a little.
>> Thank you Tibor.
>> declare @.sql nvarchar(4000)
>> declare @.db varchar(60)
>> declare @.table sysname
>> --set @.db = 'master'
>> declare cDB cursor for
>> SELECT name from master..sysdatabases sdb
>> WHERE sdb.name NOT IN ('tempdb')
>> open cDB
>> fetch cDB into @.db
>> while (@.@.fetch_status = 0)
>> begin
>> PRINT ''
>> PRINT ''
>> PRINT '=========>> ' + @.DB
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''U''
>> '
>> -- PRINT '[' + @.sql + ']'
>> EXEC sp_executesql @.sql
>> OPEN c
>> fetch from c into @.table
>> while (@.@.fetch_status = 0)
>> begin
>> print @.table
>> fetch from c into @.table
>> end
>> CLOSE c
>> DEALLOCATE c
>> fetch cDB into @.db
>> end
>> close cDB
>> deallocate cDB
>> "Jay" <nospam@.nospam.org> wrote in message news:Ob3SMap5HHA.1484@.TK2MSFTNGP06.phx.gbl...
>> declare @.sql nvarchar(4000)
>> declare @.db char(6)
>> set @.db = 'master'
>> SET @.sql = '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM ' + @.db + '.dbo.sysobjects
>> WHERE xtype = ''S''
>> '
>> EXEC @.sql
>> --OPEN c
>> (as close as I can get you example to code that will work for everyone)
>> returns:
>> Server: Msg 911, Level 16, State 1, Line 11
>> Could not locate entry in sysdatabases for database '
>> DECLARE c CURSOR FOR
>> SELECT name
>> FROM master'. No entry found with that name. Make sure that the name is entered correctly.
>>
>>
>