Showing posts with label mdf. Show all posts
Showing posts with label mdf. Show all posts

Tuesday, March 20, 2012

Rebuild Index grew database .mdf files

Hello,

Overnight, I had a Rebuild Index job run and it grew the size of the database.mdf file approximately 4 times. 300MB to 1.2GB. It also changed the initial size of the database to 1.2GB. Is there any way to recover this space or to shrink the database?

I tried to shrink it with DBCC SHRINKDATABASE to no avail (only recovered 40MB).

Do I have any options to reclaim the space?

Any ideas?

Thanks.It turns out that the cause of the increase in size of database files was due to the fact that I had the Rebuild Index job set with a fill factor of 10%. I tested a bit and found that if I set it to reorganize pages with the default amount of free space that it didn't triple/quadruple/etc the size of the files.

Case Closed!

rebuild a database from backupfile only?

Hello Rainer,
I understand that you cannot restore a database when the existing mdf/ldf
is remmoved and the database does not exist on the server. If I'm off-base,
please let me know.
You may first run fist command:
restore headeronly FROM DISK = N'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.bak'
Please see the Databasename in the result, and this shall be the database
name you use in restore command. Please double check the name is correct.
From the error message you encounter, it seems the database name is not
correct in your restore command
In my sample, it is dbacc. If run the command you mentioned, you may see
the following error message:
RESTORE DATABASE [dbacc] FROM DISK = N'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.bak' WITH FILE = 1,
NORECOVERY, REPLACE, NOUNLOAD, STATS = 10
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc.mdf"
failed with the operating system error 3(The system cannot find the path
specified.).
Msg 3156, Level 16, State 3, Line 1
File 'dbacc' cannot be restored to
'E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc.mdf'. Use WITH MOVE to identify a
valid location for the file.
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file "E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc_log.ldf"
failed with the operating system error 3(The system cannot find the path
specified.).
Msg 3156, Level 16, State 3, Line 1
File 'dbacc_log' cannot be restored to
'E:\sql2005\MSSQL.1\MSSQL\DATA\dbacc_log.ldf'. Use WITH MOVE to identify a
valid location for the file.
Msg 3119, Level 16, State 1, Line 1
Problems were identified while planning for the RESTORE statement. Previous
messages provide details.
Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
If so, you need to use "with move" statmend in restore command. For example:
RESTORE DATABASE [dbacc] FROM DISK = N'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.bak' WITH FILE = 1,
NORECOVERY, REPLACE, NOUNLOAD, STATS = 10,
move 'dbacc' to 'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc.mdf',
move 'dbacc_log' to 'C:\Program Files\Microsoft SQL
Server\MSSQL.3\MSSQL\Backup\dbacc_log.ldf'
If the issue still occurs, it might be the backup file is corrupted. You
may want to try a new backup/restore to test. Also, you may want to test
directly in QA or mangement studio(2005) to see if there is any difference
More related informaiton:
Moving SQL Server 7.0 databases to a new server with BACKUP and RESTORE
http://support.microsoft.com/kb/304692/
314546 HOW TO: Move Databases Between Computers That Are Running SQL Server
http://support.microsoft.com/?id=314546
Please let's know if you have any further questions or concerns. Thanks.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications
<http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx>.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
<http://msdn.microsoft.com/subscriptions/support/default.aspx>.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Hello Rainer,
Please feel free to post back if you have any update. :-)
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
================================================== ===
This posting is provided "AS IS" with no warranties, and confers no rights.

Rebuild .LDF File

I'm running SQL Server 2000, trying to rebuild a
transaction log since I only have an .MDF file. I've tried
creating a new database with the same name, stopping SQL
Server, then inserting the real data file, and setting the
database to emergency mode, then running the DBBC
Rebuild_Log('dbname', 'c:\somepath') and that command
appears to execute ok in Query Analyzer, but the log file
is not created. Is there any other method for attaching
the .mdf when you don't have the valid .ldf that goes with
it. (I've tried sp_attach_single_file) and that doesn't
work either. I get an error message that says it can't
find the log file (this db was pulled off of another
system that had the log file path stored pointed to
another drive). Any help is appreciated.
Thanks
Sounds like you have tried "sp_attach_single_file_db" (although this isn't
what you typed). This command to use to attach a database that only has a
the data file. I would review BOL and try this command again. Also is it
possible that you data file is corrupted?
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"Steve" <anonymous@.discussions.microsoft.com> wrote in message
news:382a01c4a55e$ce066150$a301280a@.phx.gbl...
> I'm running SQL Server 2000, trying to rebuild a
> transaction log since I only have an .MDF file. I've tried
> creating a new database with the same name, stopping SQL
> Server, then inserting the real data file, and setting the
> database to emergency mode, then running the DBBC
> Rebuild_Log('dbname', 'c:\somepath') and that command
> appears to execute ok in Query Analyzer, but the log file
> is not created. Is there any other method for attaching
> the .mdf when you don't have the valid .ldf that goes with
> it. (I've tried sp_attach_single_file) and that doesn't
> work either. I get an error message that says it can't
> find the log file (this db was pulled off of another
> system that had the log file path stored pointed to
> another drive). Any help is appreciated.
> Thanks
|||If sp_attach_single_file doesn't work then see
http://www.nigelrivett.net/RecoverCorruptDatabase.html
"Steve" wrote:

> I'm running SQL Server 2000, trying to rebuild a
> transaction log since I only have an .MDF file. I've tried
> creating a new database with the same name, stopping SQL
> Server, then inserting the real data file, and setting the
> database to emergency mode, then running the DBBC
> Rebuild_Log('dbname', 'c:\somepath') and that command
> appears to execute ok in Query Analyzer, but the log file
> is not created. Is there any other method for attaching
> the .mdf when you don't have the valid .ldf that goes with
> it. (I've tried sp_attach_single_file) and that doesn't
> work either. I get an error message that says it can't
> find the log file (this db was pulled off of another
> system that had the log file path stored pointed to
> another drive). Any help is appreciated.
> Thanks
>
|||ok, that's what I meant, I didn't check the exact syntax,
but the "sp_attach_single_file_db" doesn't work... I don't
believe the .mdf data file is corrupted. All error
messages seem to point to the log file.

>--Original Message--
>Sounds like you have tried "sp_attach_single_file_db"
(although this isn't
>what you typed). This command to use to attach a
database that only has a
>the data file. I would review BOL and try this command
again. Also is it
>possible that you data file is corrupted?
>--
>----
--
>----
--
>-
>Need SQL Server Examples check out my website
>http://www.geocities.com/sqlserverexamples
>
>"Steve" <anonymous@.discussions.microsoft.com> wrote in
message[vbcol=seagreen]
>news:382a01c4a55e$ce066150$a301280a@.phx.gbl...
tried[vbcol=seagreen]
the[vbcol=seagreen]
file[vbcol=seagreen]
with
>
>.
>
|||Ok, I just tried your instructions and it didn't work.
The database is in emergency mode, and I can't see any of
the tables, and when I try to setup a dts, I get an error
saying that it can't initialize the database.
[vbcol=seagreen]
>--Original Message--
>If sp_attach_single_file doesn't work then see
>http://www.nigelrivett.net/RecoverCorruptDatabase.html
>"Steve" wrote:
tried[vbcol=seagreen]
SQL[vbcol=seagreen]
the[vbcol=seagreen]
file[vbcol=seagreen]
with
>.
>

Rebuild .LDF File

I'm running SQL Server 2000, trying to rebuild a
transaction log since I only have an .MDF file. I've tried
creating a new database with the same name, stopping SQL
Server, then inserting the real data file, and setting the
database to emergency mode, then running the DBBC
Rebuild_Log('dbname', 'c:\somepath') and that command
appears to execute ok in Query Analyzer, but the log file
is not created. Is there any other method for attaching
the .mdf when you don't have the valid .ldf that goes with
it. (I've tried sp_attach_single_file) and that doesn't
work either. I get an error message that says it can't
find the log file (this db was pulled off of another
system that had the log file path stored pointed to
another drive). Any help is appreciated.
ThanksSounds like you have tried "sp_attach_single_file_db" (although this isn't
what you typed). This command to use to attach a database that only has a
the data file. I would review BOL and try this command again. Also is it
possible that you data file is corrupted?
--
----
----
-
Need SQL Server Examples check out my website
http://www.geocities.com/sqlserverexamples
"Steve" <anonymous@.discussions.microsoft.com> wrote in message
news:382a01c4a55e$ce066150$a301280a@.phx.gbl...
> I'm running SQL Server 2000, trying to rebuild a
> transaction log since I only have an .MDF file. I've tried
> creating a new database with the same name, stopping SQL
> Server, then inserting the real data file, and setting the
> database to emergency mode, then running the DBBC
> Rebuild_Log('dbname', 'c:\somepath') and that command
> appears to execute ok in Query Analyzer, but the log file
> is not created. Is there any other method for attaching
> the .mdf when you don't have the valid .ldf that goes with
> it. (I've tried sp_attach_single_file) and that doesn't
> work either. I get an error message that says it can't
> find the log file (this db was pulled off of another
> system that had the log file path stored pointed to
> another drive). Any help is appreciated.
> Thanks|||If sp_attach_single_file doesn't work then see
http://www.nigelrivett.net/RecoverCorruptDatabase.html
"Steve" wrote:
> I'm running SQL Server 2000, trying to rebuild a
> transaction log since I only have an .MDF file. I've tried
> creating a new database with the same name, stopping SQL
> Server, then inserting the real data file, and setting the
> database to emergency mode, then running the DBBC
> Rebuild_Log('dbname', 'c:\somepath') and that command
> appears to execute ok in Query Analyzer, but the log file
> is not created. Is there any other method for attaching
> the .mdf when you don't have the valid .ldf that goes with
> it. (I've tried sp_attach_single_file) and that doesn't
> work either. I get an error message that says it can't
> find the log file (this db was pulled off of another
> system that had the log file path stored pointed to
> another drive). Any help is appreciated.
> Thanks
>|||ok, that's what I meant, I didn't check the exact syntax,
but the "sp_attach_single_file_db" doesn't work... I don't
believe the .mdf data file is corrupted. All error
messages seem to point to the log file.
>--Original Message--
>Sounds like you have tried "sp_attach_single_file_db"
(although this isn't
>what you typed). This command to use to attach a
database that only has a
>the data file. I would review BOL and try this command
again. Also is it
>possible that you data file is corrupted?
>--
>----
--
>----
--
>-
>Need SQL Server Examples check out my website
>http://www.geocities.com/sqlserverexamples
>
>"Steve" <anonymous@.discussions.microsoft.com> wrote in
message
>news:382a01c4a55e$ce066150$a301280a@.phx.gbl...
>> I'm running SQL Server 2000, trying to rebuild a
>> transaction log since I only have an .MDF file. I've
tried
>> creating a new database with the same name, stopping SQL
>> Server, then inserting the real data file, and setting
the
>> database to emergency mode, then running the DBBC
>> Rebuild_Log('dbname', 'c:\somepath') and that command
>> appears to execute ok in Query Analyzer, but the log
file
>> is not created. Is there any other method for attaching
>> the .mdf when you don't have the valid .ldf that goes
with
>> it. (I've tried sp_attach_single_file) and that doesn't
>> work either. I get an error message that says it can't
>> find the log file (this db was pulled off of another
>> system that had the log file path stored pointed to
>> another drive). Any help is appreciated.
>> Thanks
>
>.
>|||Hi Steve.
I have a feeling that the reason it didn't work is because
you did not detatch the database first using sp_detach_db,
though that is just a gut feeling.
Unfortunatly now you have a problem, anyway you have three
choices
1. Use Nigels very interesting and funky method to restore
it
2. Restore it from backup
3. Have a pretend nervous breakdown, take down your pants
and run from the office (be it slowly) screaming (that
SHOULD stop your boss from shouting at you).
nb if you have the original database try it again either
back it up, or try an sp_detatch_db.
Peter
"There is no such thing as public opinion. There is only
published opinion."
Winston Churchill
>--Original Message--
>I'm running SQL Server 2000, trying to rebuild a
>transaction log since I only have an .MDF file. I've
tried
>creating a new database with the same name, stopping SQL
>Server, then inserting the real data file, and setting
the
>database to emergency mode, then running the DBBC
>Rebuild_Log('dbname', 'c:\somepath') and that command
>appears to execute ok in Query Analyzer, but the log file
>is not created. Is there any other method for attaching
>the .mdf when you don't have the valid .ldf that goes
with
>it. (I've tried sp_attach_single_file) and that doesn't
>work either. I get an error message that says it can't
>find the log file (this db was pulled off of another
>system that had the log file path stored pointed to
>another drive). Any help is appreciated.
>Thanks
>.
>|||Ok, I just tried your instructions and it didn't work.
The database is in emergency mode, and I can't see any of
the tables, and when I try to setup a dts, I get an error
saying that it can't initialize the database.
>--Original Message--
>If sp_attach_single_file doesn't work then see
>http://www.nigelrivett.net/RecoverCorruptDatabase.html
>"Steve" wrote:
>> I'm running SQL Server 2000, trying to rebuild a
>> transaction log since I only have an .MDF file. I've
tried
>> creating a new database with the same name, stopping
SQL
>> Server, then inserting the real data file, and setting
the
>> database to emergency mode, then running the DBBC
>> Rebuild_Log('dbname', 'c:\somepath') and that command
>> appears to execute ok in Query Analyzer, but the log
file
>> is not created. Is there any other method for attaching
>> the .mdf when you don't have the valid .ldf that goes
with
>> it. (I've tried sp_attach_single_file) and that doesn't
>> work either. I get an error message that says it can't
>> find the log file (this db was pulled off of another
>> system that had the log file path stored pointed to
>> another drive). Any help is appreciated.
>> Thanks
>.
>|||I'll buy that... I received the file from a client, who
probably just did a standard detach through EM. I'll
probably have to resort to trying to get a hold of
the .BAK file. However I might pull the 3rd suggestion
just for fun.
Thanks
>--Original Message--
>Hi Steve.
>I have a feeling that the reason it didn't work is
because
>you did not detatch the database first using
sp_detach_db,
>though that is just a gut feeling.
>Unfortunatly now you have a problem, anyway you have
three
>choices
>1. Use Nigels very interesting and funky method to
restore
>it
>2. Restore it from backup
>3. Have a pretend nervous breakdown, take down your pants
>and run from the office (be it slowly) screaming (that
>SHOULD stop your boss from shouting at you).
>nb if you have the original database try it again either
>back it up, or try an sp_detatch_db.
>Peter
>"There is no such thing as public opinion. There is only
>published opinion."
>Winston Churchill
>
>>--Original Message--
>>I'm running SQL Server 2000, trying to rebuild a
>>transaction log since I only have an .MDF file. I've
>tried
>>creating a new database with the same name, stopping SQL
>>Server, then inserting the real data file, and setting
>the
>>database to emergency mode, then running the DBBC
>>Rebuild_Log('dbname', 'c:\somepath') and that command
>>appears to execute ok in Query Analyzer, but the log
file
>>is not created. Is there any other method for attaching
>>the .mdf when you don't have the valid .ldf that goes
>with
>>it. (I've tried sp_attach_single_file) and that doesn't
>>work either. I get an error message that says it can't
>>find the log file (this db was pulled off of another
>>system that had the log file path stored pointed to
>>another drive). Any help is appreciated.
>>Thanks
>>.
>.
>|||Other ways of stopping you boss from shouting at you
include superglue...
>--Original Message--
>I'll buy that... I received the file from a client, who
>probably just did a standard detach through EM. I'll
>probably have to resort to trying to get a hold of
>the .BAK file. However I might pull the 3rd suggestion
>just for fun.
>Thanks
>
>>--Original Message--
>>Hi Steve.
>>I have a feeling that the reason it didn't work is
>because
>>you did not detatch the database first using
>sp_detach_db,
>>though that is just a gut feeling.
>>Unfortunatly now you have a problem, anyway you have
>three
>>choices
>>1. Use Nigels very interesting and funky method to
>restore
>>it
>>2. Restore it from backup
>>3. Have a pretend nervous breakdown, take down your
pants
>>and run from the office (be it slowly) screaming (that
>>SHOULD stop your boss from shouting at you).
>>nb if you have the original database try it again either
>>back it up, or try an sp_detatch_db.
>>Peter
>>"There is no such thing as public opinion. There is only
>>published opinion."
>>Winston Churchill
>>
>>--Original Message--
>>I'm running SQL Server 2000, trying to rebuild a
>>transaction log since I only have an .MDF file. I've
>>tried
>>creating a new database with the same name, stopping
SQL
>>Server, then inserting the real data file, and setting
>>the
>>database to emergency mode, then running the DBBC
>>Rebuild_Log('dbname', 'c:\somepath') and that command
>>appears to execute ok in Query Analyzer, but the log
>file
>>is not created. Is there any other method for attaching
>>the .mdf when you don't have the valid .ldf that goes
>>with
>>it. (I've tried sp_attach_single_file) and that doesn't
>>work either. I get an error message that says it can't
>>find the log file (this db was pulled off of another
>>system that had the log file path stored pointed to
>>another drive). Any help is appreciated.
>>Thanks
>>.
>>.
>.
>

Friday, March 9, 2012

Reattaching old database

I have just installed SQLExpress version 9.0.1399.

I was using an earlier version of the server before and backed up a copy of my mdf files for safety's sake. However when I now try and attach the old databases I get an error that the database files from the old non-release version (590) is not compatible.

Probably my own fault - the information was probably clearly on display deep in a file somewhere in the documentation (cough). However I would kind of like to get at the data in these files.

Is there any way of getting hold of an earlier version of SQLExpress which will handle these files? Or can they be opened in any other way?

The full error message I am getting is:

Database 'myCMS' cannot be upgraded because its non-release version (590) is not supported by this version of SQL Server. You cannot open a database that is incompatible with this version of sqlservr.exe. You must re-create the database. (Microsoft SQL Server, Error: 950)

I have searched around for more information and the advice seems to be that I should open the database in an older copy of SQLExpress, dump the data with BCP and recreate the database.

So now my question is, where can I find installation files for earlier versions of SQLExpress as I don't seem to have a copy of the original executable?

|||I am afraid these are no longer available, you might be able to get them by calling Customer Support Services but this will cost money