Showing posts with label partition. Show all posts
Showing posts with label partition. Show all posts

Monday, March 26, 2012

How to remove a partition completely

Hello,

I'm testing partitions and all works well except removing partitions. My steps for removing the oldest partition of a partitioned table:

a) CREATE TABLE I'm creating a new temporary table with the same structure and indexes as the partitioned one - in the same filegroup as the first partition ==> OK

b) ALTER TABLE I'm switching out the oldest partition to the new table => OK

c) ALTER PARTITION FUNCTION I'm merging the oldest boundary value == OK

I have checked, that all old data rows are "removed" from the partitioned table. Then I drop the temporary table and remove the file from the file group.

Checking Database Properties > Filegroups shows there are 0 files in the file group. When I try to remove the file group I get an error

Quote: Drop failed for FileGroup 'fgtrans000000'. (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The filegroup 'fgtrans000000' cannot be removed because it is not empty. (Microsoft SQL Server, Error: 5042)

Thank you

Eckard

I managed to solve the problem:

When the partition function is defined AS RANGE RIGHT, then merging the oldest partitions means removing the second oldest file group from the partition scheme! Since the oldest file group is reused I could not remove the file group. It's descibed in the documentation, ok.

But that was not what I excepected. I thought the oldest file group would be removed. It's symmetric with the other end: If I split the newest partition the new file group gets inserted before (!) the newest one if I get RANGE RIGHT or LEFT wrong.

IMHO this should not depend on the RANGE RIGHT or LEFT definition.

Eckard

sql

How to remove a partition completely

Hello,

I'm testing partitions and all works well except removing partitions. My steps for removing the oldest partition of a partitioned table:

a) CREATE TABLE I'm creating a new temporary table with the same structure and indexes as the partitioned one - in the same filegroup as the first partition ==> OK

b) ALTER TABLE I'm switching out the oldest partition to the new table => OK

c) ALTER PARTITION FUNCTION I'm merging the oldest boundary value == OK

I have checked, that all old data rows are "removed" from the partitioned table. Then I drop the temporary table and remove the file from the file group.

Checking Database Properties > Filegroups shows there are 0 files in the file group. When I try to remove the file group I get an error

Quote: Drop failed for FileGroup 'fgtrans000000'. (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
The filegroup 'fgtrans000000' cannot be removed because it is not empty. (Microsoft SQL Server, Error: 5042)

Thank you

Eckard

I managed to solve the problem:

When the partition function is defined AS RANGE RIGHT, then merging the oldest partitions means removing the second oldest file group from the partition scheme! Since the oldest file group is reused I could not remove the file group. It's descibed in the documentation, ok.

But that was not what I excepected. I thought the oldest file group would be removed. It's symmetric with the other end: If I split the newest partition the new file group gets inserted before (!) the newest one if I get RANGE RIGHT or LEFT wrong.

IMHO this should not depend on the RANGE RIGHT or LEFT definition.

Eckard

Monday, March 12, 2012

HOw to recover a database from the .LDF file.

Hi,
Due to a hardware problem I lost my mydatabase.MDF file, but my
mydatabase.LDF file is still OK because it is on another partition. I can
restore the database, but (here comes Murphy) the tape containing the
transaction logs backups is corrupt too. Since my last full backup I made
transaction log backups with the NO_TRUNCATE option, so everything should be
in the mydatabase.LDF file. After restoring the database in no_recover mode,
how can I apply the transactions that are still in mydatabase.LDF file
(NO_TRUNCATE)?
Any help is welcome.
Thanks
Felix> Since my last full backup I made
> transaction log backups with the NO_TRUNCATE option, so everything should be
> in the mydatabase.LDF file.
I'm afraid not. The name of that option is misleading. See
http://www.karaszi.com/SQLServer/info_restore_no_truncate.asp
Your best bet is probably to use a log reader tool and see if you can salvage anything from the
existing log backup. But, as per the article, the information in the prior log backups is most
probably lost. You might want to open a case with MS Support and see if they have anything up their
sleeves.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Felix" <Felix@.discussions.microsoft.com> wrote in message
news:D686735A-BF91-40EA-BBD3-16ED67B13E3B@.microsoft.com...
> Hi,
> Due to a hardware problem I lost my mydatabase.MDF file, but my
> mydatabase.LDF file is still OK because it is on another partition. I can
> restore the database, but (here comes Murphy) the tape containing the
> transaction logs backups is corrupt too. Since my last full backup I made
> transaction log backups with the NO_TRUNCATE option, so everything should be
> in the mydatabase.LDF file. After restoring the database in no_recover mode,
> how can I apply the transactions that are still in mydatabase.LDF file
> (NO_TRUNCATE)?
> Any help is welcome.
> Thanks
> Felix|||Hi Tibor,
Thanks for your answer, this helped us a lot.
Lucky enough, this was not a production database, but a test we were
performing.
Indead, the NO_TRUNCATE is misleading.
This means also that you are only able to restore till the time of failure
if you are able to backup the still existing logs first, else you can only
restore untill the latest log backup. This means that you should backup as
often as possible for critical DB's!
Kind regards
Felix
"Tibor Karaszi" wrote:
> > Since my last full backup I made
> > transaction log backups with the NO_TRUNCATE option, so everything should be
> > in the mydatabase.LDF file.
> I'm afraid not. The name of that option is misleading. See
> http://www.karaszi.com/SQLServer/info_restore_no_truncate.asp
> Your best bet is probably to use a log reader tool and see if you can salvage anything from the
> existing log backup. But, as per the article, the information in the prior log backups is most
> probably lost. You might want to open a case with MS Support and see if they have anything up their
> sleeves.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Felix" <Felix@.discussions.microsoft.com> wrote in message
> news:D686735A-BF91-40EA-BBD3-16ED67B13E3B@.microsoft.com...
> > Hi,
> > Due to a hardware problem I lost my mydatabase.MDF file, but my
> > mydatabase.LDF file is still OK because it is on another partition. I can
> > restore the database, but (here comes Murphy) the tape containing the
> > transaction logs backups is corrupt too. Since my last full backup I made
> > transaction log backups with the NO_TRUNCATE option, so everything should be
> > in the mydatabase.LDF file. After restoring the database in no_recover mode,
> > how can I apply the transactions that are still in mydatabase.LDF file
> > (NO_TRUNCATE)?
> >
> > Any help is welcome.
> >
> > Thanks
> >
> > Felix
>

HOw to recover a database from the .LDF file.

Hi,
Due to a hardware problem I lost my mydatabase.MDF file, but my
mydatabase.LDF file is still OK because it is on another partition. I can
restore the database, but (here comes Murphy) the tape containing the
transaction logs backups is corrupt too. Since my last full backup I made
transaction log backups with the NO_TRUNCATE option, so everything should be
in the mydatabase.LDF file. After restoring the database in no_recover mode,
how can I apply the transactions that are still in mydatabase.LDF file
(NO_TRUNCATE)?
Any help is welcome.
Thanks
Felix
> Since my last full backup I made
> transaction log backups with the NO_TRUNCATE option, so everything should be
> in the mydatabase.LDF file.
I'm afraid not. The name of that option is misleading. See
http://www.karaszi.com/SQLServer/inf...o_truncate.asp
Your best bet is probably to use a log reader tool and see if you can salvage anything from the
existing log backup. But, as per the article, the information in the prior log backups is most
probably lost. You might want to open a case with MS Support and see if they have anything up their
sleeves.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Felix" <Felix@.discussions.microsoft.com> wrote in message
news:D686735A-BF91-40EA-BBD3-16ED67B13E3B@.microsoft.com...
> Hi,
> Due to a hardware problem I lost my mydatabase.MDF file, but my
> mydatabase.LDF file is still OK because it is on another partition. I can
> restore the database, but (here comes Murphy) the tape containing the
> transaction logs backups is corrupt too. Since my last full backup I made
> transaction log backups with the NO_TRUNCATE option, so everything should be
> in the mydatabase.LDF file. After restoring the database in no_recover mode,
> how can I apply the transactions that are still in mydatabase.LDF file
> (NO_TRUNCATE)?
> Any help is welcome.
> Thanks
> Felix
|||Hi Tibor,
Thanks for your answer, this helped us a lot.
Lucky enough, this was not a production database, but a test we were
performing.
Indead, the NO_TRUNCATE is misleading.
This means also that you are only able to restore till the time of failure
if you are able to backup the still existing logs first, else you can only
restore untill the latest log backup. This means that you should backup as
often as possible for critical DB's!
Kind regards
Felix
"Tibor Karaszi" wrote:

> I'm afraid not. The name of that option is misleading. See
> http://www.karaszi.com/SQLServer/inf...o_truncate.asp
> Your best bet is probably to use a log reader tool and see if you can salvage anything from the
> existing log backup. But, as per the article, the information in the prior log backups is most
> probably lost. You might want to open a case with MS Support and see if they have anything up their
> sleeves.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Felix" <Felix@.discussions.microsoft.com> wrote in message
> news:D686735A-BF91-40EA-BBD3-16ED67B13E3B@.microsoft.com...
>

HOw to recover a database from the .LDF file.

Hi,
Due to a hardware problem I lost my mydatabase.MDF file, but my
mydatabase.LDF file is still OK because it is on another partition. I can
restore the database, but (here comes Murphy) the tape containing the
transaction logs backups is corrupt too. Since my last full backup I made
transaction log backups with the NO_TRUNCATE option, so everything should be
in the mydatabase.LDF file. After restoring the database in no_recover mode,
how can I apply the transactions that are still in mydatabase.LDF file
(NO_TRUNCATE)?
Any help is welcome.
Thanks
Felix> Since my last full backup I made
> transaction log backups with the NO_TRUNCATE option, so everything should
be
> in the mydatabase.LDF file.
I'm afraid not. The name of that option is misleading. See
http://www.karaszi.com/SQLServer/in...no_truncate.asp
Your best bet is probably to use a log reader tool and see if you can salvag
e anything from the
existing log backup. But, as per the article, the information in the prior l
og backups is most
probably lost. You might want to open a case with MS Support and see if they
have anything up their
sleeves.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Felix" <Felix@.discussions.microsoft.com> wrote in message
news:D686735A-BF91-40EA-BBD3-16ED67B13E3B@.microsoft.com...
> Hi,
> Due to a hardware problem I lost my mydatabase.MDF file, but my
> mydatabase.LDF file is still OK because it is on another partition. I can
> restore the database, but (here comes Murphy) the tape containing the
> transaction logs backups is corrupt too. Since my last full backup I made
> transaction log backups with the NO_TRUNCATE option, so everything should
be
> in the mydatabase.LDF file. After restoring the database in no_recover mod
e,
> how can I apply the transactions that are still in mydatabase.LDF file
> (NO_TRUNCATE)?
> Any help is welcome.
> Thanks
> Felix|||Hi Tibor,
Thanks for your answer, this helped us a lot.
Lucky enough, this was not a production database, but a test we were
performing.
Indead, the NO_TRUNCATE is misleading.
This means also that you are only able to restore till the time of failure
if you are able to backup the still existing logs first, else you can only
restore untill the latest log backup. This means that you should backup as
often as possible for critical DB's!
Kind regards
Felix
"Tibor Karaszi" wrote:

> I'm afraid not. The name of that option is misleading. See
> http://www.karaszi.com/SQLServer/in...no_truncate.asp
> Your best bet is probably to use a log reader tool and see if you can salv
age anything from the
> existing log backup. But, as per the article, the information in the prior
log backups is most
> probably lost. You might want to open a case with MS Support and see if th
ey have anything up their
> sleeves.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "Felix" <Felix@.discussions.microsoft.com> wrote in message
> news:D686735A-BF91-40EA-BBD3-16ED67B13E3B@.microsoft.com...
>