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

Thursday, March 29, 2012

Database startup

in sql server (re)start where does it find the location of Master.mdf file .

In Oracle, there is control file where the location of *.dbf file is stored and Instance find the location of dbf file from that location

In sql server where it finds the location of Databases as master, msdb etc..

The location is set duing Server installation.

That information is stored in the registry. It can also be supplied as a command line start up parameter [ -dMasterFilePath ].

The registry location 'should' be:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\Parameters

Thursday, March 22, 2012

Database Size

Hi,
I have create Database with size 200 md and 40 mb for mdf and ldf
respectively (Fixed Size - not go grow or shrink) while creating database,
using wizard, little later i checked database size it became with default
size automatically.
How can I create database with Fixed size
Thanks
Mothi KannanIn sql Enterprise Manager right click your database and use the data and log
tabs to set the sizes. be sure to uncheck the autogrow stuff..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Mothi" <Mothi@.discussions.microsoft.com> wrote in message
news:2AAF530A-5462-4E60-8D28-D76D7429DFC4@.microsoft.com...
> Hi,
> I have create Database with size 200 md and 40 mb for mdf and ldf
> respectively (Fixed Size - not go grow or shrink) while creating database,
> using wizard, little later i checked database size it became with default
> size automatically.
> How can I create database with Fixed size
> Thanks
> Mothi Kannan

Database Size

Hi,
I have create Database with size 200 md and 40 mb for mdf and ldf
respectively (Fixed Size - not go grow or shrink) while creating database,
using wizard, little later i checked database size it became with default
size automatically.
How can I create database with Fixed size
Thanks
Mothi KannanIn sql Enterprise Manager right click your database and use the data and log
tabs to set the sizes. be sure to uncheck the autogrow stuff..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Mothi" <Mothi@.discussions.microsoft.com> wrote in message
news:2AAF530A-5462-4E60-8D28-D76D7429DFC4@.microsoft.com...
> Hi,
> I have create Database with size 200 md and 40 mb for mdf and ldf
> respectively (Fixed Size - not go grow or shrink) while creating database,
> using wizard, little later i checked database size it became with default
> size automatically.
> How can I create database with Fixed size
> Thanks
> Mothi Kannan

Wednesday, March 21, 2012

Database Size

Hi,
I have create Database with size 200 md and 40 mb for mdf and ldf
respectively (Fixed Size - not go grow or shrink) while creating database,
using wizard, little later i checked database size it became with default
size automatically.
How can I create database with Fixed size
Thanks
Mothi Kannan
In sql Enterprise Manager right click your database and use the data and log
tabs to set the sizes. be sure to uncheck the autogrow stuff..
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Mothi" <Mothi@.discussions.microsoft.com> wrote in message
news:2AAF530A-5462-4E60-8D28-D76D7429DFC4@.microsoft.com...
> Hi,
> I have create Database with size 200 md and 40 mb for mdf and ldf
> respectively (Fixed Size - not go grow or shrink) while creating database,
> using wizard, little later i checked database size it became with default
> size automatically.
> How can I create database with Fixed size
> Thanks
> Mothi Kannan

database showing suspect

I moved a database file (.mdf) from the Microsoft SQL Server data directory to another location, and moved it back into the original location. After which the database staus changed to suspect.
How do I make it live? ThanksRead up on sp_resetstatus in the Books online.

Database server will not expand mdf or ndf files

Has anyone had an issue with SQL Server not being able to expand
against a RAID 5 file system? My current configuration is that the
server is started and stopped using the local system account. I have
only one database (besides the master, model,etc)on the server. What
has happend to me several times is that the primary database in
question try's to expand the main datafile for the database (.mdf). I
setup the database to not expand automatically initially so that I can
be sure that we have enough file system space. Becuase of problems with
the application I decided to automatically expand. The other day the
developers came to me indicating that the databse was full and needed
to be expanded. Knowing that the database was in automatic expanding
more I was surprise to hear this. I went into EM and attempted to
expand first the log and it would not indicating that it there was an
issue in attempting to do so. I have never heard of a database not
being able to expand. I ran DBCC's, etc and it came up clean. I tried
to back the database up to disk and it would not backup. I finally had
to rename the datbase and rebuild it using DTS and scripts. I thought
I had fixed it only to find out today that it (again) won't expand. I
renamed the datbase and then tried taking an older backup file and
restore it and it would not restore. This problem seems to be related
to the file system but how I do not know.

So, I am ready to run rebuild master but I have sone this before only
to have this come back on me. I am at a complete loss. In the past I
have had to rebuild the entire server and database from scratch. The
only problem is that this has been done 3 times now with no complete
solution or explaination. If any of you have seen this type of
behavior and know whats going on please, please let me know what you
think the case and solution is!"2centbob" wrote:

> Has anyone had an issue with SQL Server not being able to expand
> against a RAID 5 file system? My current configuration is that the
> server is started and stopped using the local system account. I have
> only one database (besides the master, model,etc)on the server. What
> has happend to me several times is that the primary database in
> question try's to expand the main datafile for the database (.mdf). I
> setup the database to not expand automatically initially so that I can
> be sure that we have enough file system space. Becuase of problems with
> the application I decided to automatically expand. The other day the
> developers came to me indicating that the databse was full and needed
> to be expanded. Knowing that the database was in automatic expanding
> more I was surprise to hear this. I went into EM and attempted to
> expand first the log and it would not indicating that it there was an
> issue in attempting to do so. I have never heard of a database not
> being able to expand. I ran DBCC's, etc and it came up clean. I tried
> to back the database up to disk and it would not backup. I finally had
> to rename the datbase and rebuild it using DTS and scripts. I thought
> I had fixed it only to find out today that it (again) won't expand. I
> renamed the datbase and then tried taking an older backup file and
> restore it and it would not restore. This problem seems to be related
> to the file system but how I do not know.

<snip
I don't know of issues specifically with RAID 5 (unless your RAID card has
gone bonkers), but here's a few guesses (mostly based on my trying to figure
out why the file system or something else would stop a file from expanding).

- Are you sure you have enough disk space? (I'm pretty that's not it and you
would have seen it, but better safe than sorry.) One place to look is
programs that might create huge temp files that eventually go away: we had a
server that ran multiple concurrent server processes. We had a heck of a
time figuring out why disk space seemingly came and went in huge chunks
until we realized that 3rd party code in our services was creating *huge*
temp files (because a few programmers didn't code for users requesting
reports with 4 million lines before control breaks :).

- Is your file system NTFS or FAT? Not being able to expand and then not
being able to backup or restore sounds fishy: could you be bumping into
FAT's file size limit? If I recall it's 4GB in FAT32 and 2GB in earlier FAT
versions.

- Are disk quotas enabled on the server? I've never even touched these in
Windows, so I have no idea where you would look... For that matter, does
your RAID hw/sw combo allow for any kind of quota?

- I'm pretty sure you already have, but in case you haven't, have you
checked the SQL Server logs and the OS event logs?

Good Luck,

Craig|||Thanks for your reply. In these cases its allways novce to have a
complete picture and that doesn't necessarly get conveyed sometimes.
So, a little more information is warrented. The application that uses
the database is a Java app sitting on a different server. The database
server has no application running on it. The application was written by
a vendor. Thier requirements require that the datbase owner have full
rights to the database, i.e., using sp_changedbowner to that user. If I
did not use that approach then the application had problems upon
installation and therefore would not properly install. So, as I said I
changed it. Prior to this expereince the database was left to expand as
it needed and it did with no issues. The two circumstances that I
refered in my earlier email: the file system filled up and the database
could not expand. In addition, the server could not be reached and so
we had to shut it down hard. When it came back up we could not use the
database nor could we back it up. We were forced to rebuild the server:
OS and SQL Server. Later, a similar incident happened again and we were
forced (again) to rebuild. This last time, I had an additional 40 GB
added so we would not have a file system space problem again. I put the
database and log into a non-expansion mode so that when the application
would not accidently consume all of the disk space. However, the
database hit the high water mark on the datafile and could not expand.
I was notofied and of the problem and went to expand the file and it
would not expand again. No you most of the information.

At this point I am starting to think that as long the database has file
space to expand into and is not resitricted in any way the application
would probably work alright. However, because "sa" does not own the
database, the database owner probably needs "sa" rights. This is just
conjecture at this point. Funny thing, when this happend, the last
time, the "TaskPad" information came up with an error saying it could
not display the information and wanted to me to stop running the rest of
the script. I am concered that OS files are being walked on somehow.

Boy, I never had this expereince using Sybase and I have never seen
anyting like it in Oracle as well. But then again those were Unix
databases that I worked on, and not Windows.

Thanks.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Bob Schmitz (bschmitz4@.wi.rr.com) writes:
> Thanks for your reply. In these cases its allways novce to have a
> complete picture and that doesn't necessarly get conveyed sometimes.
> So, a little more information is warrented. The application that uses
> the database is a Java app sitting on a different server. The database
> server has no application running on it. The application was written by
> a vendor. Thier requirements require that the datbase owner have full
> rights to the database, i.e., using sp_changedbowner to that user. If I
> did not use that approach then the application had problems upon
> installation and therefore would not properly install. So, as I said I
> changed it. Prior to this expereince the database was left to expand as
> it needed and it did with no issues. The two circumstances that I
> refered in my earlier email: the file system filled up and the database
> could not expand. In addition, the server could not be reached and so
> we had to shut it down hard. When it came back up we could not use the
> database nor could we back it up. We were forced to rebuild the server:
> OS and SQL Server. Later, a similar incident happened again and we were
> forced (again) to rebuild. This last time, I had an additional 40 GB
> added so we would not have a file system space problem again. I put the
> database and log into a non-expansion mode so that when the application
> would not accidently consume all of the disk space. However, the
> database hit the high water mark on the datafile and could not expand.
> I was notofied and of the problem and went to expand the file and it
> would not expand again. No you most of the information.

A lots of words, but, frankly, not very much information.

First of all, who owns the database does not matter. Auto-grow will
work anyway.

Since you seem to have difficulties to explain what is going on, I would
like you to run sp_helpdb on your database and post the output. That
will at least give some minimum of information for us to work from.

I would also like you do a DIR on the disks where the data and log files
reside, and post the bottom lines from that output.

In your previous message you said that you could not backup the database,
but you never explained why. Did you get an error message? Or how did
you conclude that the backup wasn't working?

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Hi

Even though you mention EM! Are you using MSDE?
Do you have disk quotas?
Are you using mount points?

It may help if you posted the version
http://www.aspfaq.com/show.asp?id=2160.

John

"Bob Schmitz" <bschmitz4@.wi.rr.com> wrote in message
news:4204f360$1_2@.127.0.0.1...
> Thanks for your reply. In these cases its allways novce to have a
> complete picture and that doesn't necessarly get conveyed sometimes.
> So, a little more information is warrented. The application that uses
> the database is a Java app sitting on a different server. The database
> server has no application running on it. The application was written by
> a vendor. Thier requirements require that the datbase owner have full
> rights to the database, i.e., using sp_changedbowner to that user. If I
> did not use that approach then the application had problems upon
> installation and therefore would not properly install. So, as I said I
> changed it. Prior to this expereince the database was left to expand as
> it needed and it did with no issues. The two circumstances that I
> refered in my earlier email: the file system filled up and the database
> could not expand. In addition, the server could not be reached and so
> we had to shut it down hard. When it came back up we could not use the
> database nor could we back it up. We were forced to rebuild the server:
> OS and SQL Server. Later, a similar incident happened again and we were
> forced (again) to rebuild. This last time, I had an additional 40 GB
> added so we would not have a file system space problem again. I put the
> database and log into a non-expansion mode so that when the application
> would not accidently consume all of the disk space. However, the
> database hit the high water mark on the datafile and could not expand.
> I was notofied and of the problem and went to expand the file and it
> would not expand again. No you most of the information.
> At this point I am starting to think that as long the database has file
> space to expand into and is not resitricted in any way the application
> would probably work alright. However, because "sa" does not own the
> database, the database owner probably needs "sa" rights. This is just
> conjecture at this point. Funny thing, when this happend, the last
> time, the "TaskPad" information came up with an error saying it could
> not display the information and wanted to me to stop running the rest of
> the script. I am concered that OS files are being walked on somehow.
> Boy, I never had this expereince using Sybase and I have never seen
> anyting like it in Oracle as well. But then again those were Unix
> databases that I worked on, and not Windows.
> Thanks.
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!|||Thats becuase this was a very difficult and weird situation. I knew
that I would not be able to explain it all and some would have
questions. sp_helpdb is not the problem becuase it shows the database.
There are no errors in the logs except when I try to backup or if i
tried to restore the database in question. When I ran a dir on the
filesystem the database files and there sizes show that they have
expanded but the databsae does no reflect this.

Now, what I have doen since then is to blow away the master, model,
msdb, and tempdb. I then ran the rebuild.exe program. That seems to
have fixed the problem as after I reattached the database I was able to
expand but log and data.

2centbob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Bob Schmitz (bschmitz4@.wi.rr.com) writes:
> Thats becuase this was a very difficult and weird situation. I knew
> that I would not be able to explain it all and some would have
> questions. sp_helpdb is not the problem becuase it shows the database.
> There are no errors in the logs except when I try to backup or if i
> tried to restore the database in question. When I ran a dir on the
> filesystem the database files and there sizes show that they have
> expanded but the databsae does no reflect this.
> Now, what I have doen since then is to blow away the master, model,
> msdb, and tempdb. I then ran the rebuild.exe program. That seems to
> have fixed the problem as after I reattached the database I was able to
> expand but log and data.

I strongly suspect that you put far more work into fix this that was
required.

However, since your choice is not to share the information I asked you
to, I'm afraid I can't help you with advice of what you should have done.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||You can suspect all you want ... Unless you had been there working side
by side you don't know anything. Not only that, I resent your attitude
as though you know more than anyone else on this site. Please, in the
future, if you dont have something say other than criticize someone,
please refrain from responding. I don't need it and suspect others
don't need it as well.

For others: The end users were screaming to have this system back and so
my time was limited in responding. THE ONLY THING THAT HAS WORKED HAS
BEEN TO REBUILD THE MASTER DATABASE. Be that as it may, it works now,
thanks to all that replied.

2centbob

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!|||Bob Schmitz (bschmitz4@.wi.rr.com) writes:
> You can suspect all you want ... Unless you had been there working side
> by side you don't know anything. Not only that, I resent your attitude
> as though you know more than anyone else on this site. Please, in the
> future, if you don't have something say other than criticize someone,
> please refrain from responding. I don't need it and suspect others
> don't need it as well.

You appeared to ask for help. And that's basically what I do here. Try
to help people. But often, I need more information about the case, so I
ask for that. It's true, that I have not been on your site, so I don't
know what happened. I have however been trying to find out, but you have
been very willing to give me the information that I have asked for. Of
course, you may do as you please. But you cannot really expect to get any
useful assistence that way.

And that is a piece of advice for the future when you have a need to
ask for help.

> For others: The end users were screaming to have this system back and so
> my time was limited in responding.

It may be better in a situation like this to open a case with Microsoft
support. It's certainly more expensive than a free forum like this one.
Then again, if they can help to reduce downtime, you get the money back
that way. Of course, also the support engineers will ask you questions
about the configuration, error messages etc.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp

Saturday, February 25, 2012

Database Renaming

Can anyone suggest a quick and easy way to rename a database AND .MDF/.LDF file in SQL Server?
I can not, for the life of me, figure out a way to do this.
Help?You could try to backup database and restore it with another name like this (before restoring you may delete old database).

Old db name is rDB, new will be rrDB.

RESTORE DATABASE rrDB
FROM DISK = 'w:\rdb.bak'
WITH MOVE 'rDB_Data' TO 'w:\rrDB.mdf',
MOVE 'rDB_Log' TO 'w:\rrDB.ldf'|||Originally posted by JBoyce
Can anyone suggest a quick and easy way to rename a database AND .MDF/.LDF file in SQL Server?
I can not, for the life of me, figure out a way to do this.
Help?
You can also use sp_renamedb|||Originally posted by smasanam
You can also use sp_renamedb

But file names will be the same...|||"Alter database" has a way to rename logical files, but the physical files will remain the same. If the DB name and the filenames all have to change, then Snail has the right way to go.

Database removable

Hello,is possible attach and use the mdf exists in a pen drive or an usb
hard disk ?
What commands are involved in this operation ?
Thanks in advance.
I have a lot of DB allocated on my USB (or Firewire) external disk; even a
pen drive is managed by the OS as an external, removable disk.
The only attention you hav to pay is to remember detach you removable
database when you suppose the next startup of your PC will be without the
external disks containing your databases.
When you need to use such databases you'll attach it again
Gilberto
"Luis Tarzia" wrote:

> Hello,is possible attach and use the mdf exists in a pen drive or an usb
> hard disk ?
> What commands are involved in this operation ?
> Thanks in advance.
>
>
|||I attach the mdf with the sp_attachd but when i execute any sql command the
sql mark an error of access a memory and exit.
"Gilberto Zampatti" <GilbertoZampatti@.discussions.microsoft.com> escribi en
el mensaje news:5BF5A51B-83A5-4A23-B540-B104BBCDD7AC@.microsoft.com...
> I have a lot of DB allocated on my USB (or Firewire) external disk; even
a[vbcol=seagreen]
> pen drive is managed by the OS as an external, removable disk.
> The only attention you hav to pay is to remember detach you removable
> database when you suppose the next startup of your PC will be without the
> external disks containing your databases.
> When you need to use such databases you'll attach it again
> Gilberto
> "Luis Tarzia" wrote:

Database removable

Hello,is possible attach and use the mdf exists in a pen drive or an usb
hard disk ?
What commands are involved in this operation '
Thanks in advance.I have a lot of DB allocated on my USB (or Firewire) external disk; even a
pen drive is managed by the OS as an external, removable disk.
The only attention you hav to pay is to remember detach you removable
database when you suppose the next startup of your PC will be without the
external disks containing your databases.
When you need to use such databases you'll attach it again
Gilberto
"Luis Tarzia" wrote:

> Hello,is possible attach and use the mdf exists in a pen drive or an usb
> hard disk ?
> What commands are involved in this operation '
> Thanks in advance.
>
>|||I attach the mdf with the sp_attachd but when i execute any sql command the
sql mark an error of access a memory and exit.
"Gilberto Zampatti" <GilbertoZampatti@.discussions.microsoft.com> escribi en
el mensaje news:5BF5A51B-83A5-4A23-B540-B104BBCDD7AC@.microsoft.com...
> I have a lot of DB allocated on my USB (or Firewire) external disk; even
a[vbcol=seagreen]
> pen drive is managed by the OS as an external, removable disk.
> The only attention you hav to pay is to remember detach you removable
> database when you suppose the next startup of your PC will be without the
> external disks containing your databases.
> When you need to use such databases you'll attach it again
> Gilberto
> "Luis Tarzia" wrote:
>

Database removable

Hello,is possible attach and use the mdf exists in a pen drive or an usb
hard disk ?
What commands are involved in this operation '
Thanks in advance.I have a lot of DB allocated on my USB (or Firewire) external disk; even a
pen drive is managed by the OS as an external, removable disk.
The only attention you hav to pay is to remember detach you removable
database when you suppose the next startup of your PC will be without the
external disks containing your databases.
When you need to use such databases you'll attach it again
Gilberto
"Luis Tarzia" wrote:
> Hello,is possible attach and use the mdf exists in a pen drive or an usb
> hard disk ?
> What commands are involved in this operation '
> Thanks in advance.
>
>|||I attach the mdf with the sp_attachd but when i execute any sql command the
sql mark an error of access a memory and exit.
"Gilberto Zampatti" <GilbertoZampatti@.discussions.microsoft.com> escribió en
el mensaje news:5BF5A51B-83A5-4A23-B540-B104BBCDD7AC@.microsoft.com...
> I have a lot of DB allocated on my USB (or Firewire) external disk; even
a
> pen drive is managed by the OS as an external, removable disk.
> The only attention you hav to pay is to remember detach you removable
> database when you suppose the next startup of your PC will be without the
> external disks containing your databases.
> When you need to use such databases you'll attach it again
> Gilberto
> "Luis Tarzia" wrote:
> > Hello,is possible attach and use the mdf exists in a pen drive or an usb
> > hard disk ?
> > What commands are involved in this operation '
> > Thanks in advance.
> >
> >
> >

Friday, February 24, 2012

Database Recovery Issue

We had a hard drive crash on one of our servers. There are no backups of the
database available but we were able to recover the MDF and LDf for the only
database that was on the server. The server had to be rebuilt and SQL
reinstalled. The question I have, is there a way to recover this database
using the MDF and LDF files. I tried using the sp_attach_db command but
without much success (don't know if I used the wrong parameters or what). Any
suggestions would be greatly appreciated.There are several possibilities depending on the state of the database and
files involved. Your best bet is to contact PSS
(http://support.microsoft.com) who will be able to help you get up and
running again (and fix your backup process, of course :-)
Regards.
--
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"MACason" <MACason@.discussions.microsoft.com> wrote in message
news:987BCD70-4AD9-42A6-AF66-CBB37EECB647@.microsoft.com...
> We had a hard drive crash on one of our servers. There are no backups of
the
> database available but we were able to recover the MDF and LDf for the
only
> database that was on the server. The server had to be rebuilt and SQL
> reinstalled. The question I have, is there a way to recover this database
> using the MDF and LDF files. I tried using the sp_attach_db command but
> without much success (don't know if I used the wrong parameters or what).
Any
> suggestions would be greatly appreciated.

Database Recovery Issue

We had a hard drive crash on one of our servers. There are no backups of the
database available but we were able to recover the MDF and LDf for the only
database that was on the server. The server had to be rebuilt and SQL
reinstalled. The question I have, is there a way to recover this database
using the MDF and LDF files. I tried using the sp_attach_db command but
without much success (don't know if I used the wrong parameters or what). Any
suggestions would be greatly appreciated.
There are several possibilities depending on the state of the database and
files involved. Your best bet is to contact PSS
(http://support.microsoft.com) who will be able to help you get up and
running again (and fix your backup process, of course :-)
Regards.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"MACason" <MACason@.discussions.microsoft.com> wrote in message
news:987BCD70-4AD9-42A6-AF66-CBB37EECB647@.microsoft.com...
> We had a hard drive crash on one of our servers. There are no backups of
the
> database available but we were able to recover the MDF and LDf for the
only
> database that was on the server. The server had to be rebuilt and SQL
> reinstalled. The question I have, is there a way to recover this database
> using the MDF and LDF files. I tried using the sp_attach_db command but
> without much success (don't know if I used the wrong parameters or what).
Any
> suggestions would be greatly appreciated.

Database Recovery Issue

We had a hard drive crash on one of our servers. There are no backups of the
database available but we were able to recover the MDF and LDf for the only
database that was on the server. The server had to be rebuilt and SQL
reinstalled. The question I have, is there a way to recover this database
using the MDF and LDF files. I tried using the sp_attach_db command but
without much success (don't know if I used the wrong parameters or what). An
y
suggestions would be greatly appreciated.There are several possibilities depending on the state of the database and
files involved. Your best bet is to contact PSS
(http://support.microsoft.com) who will be able to help you get up and
running again (and fix your backup process, of course :-)
Regards.
Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
This posting is provided "AS IS" with no warranties, and confers no rights.
"MACason" <MACason@.discussions.microsoft.com> wrote in message
news:987BCD70-4AD9-42A6-AF66-CBB37EECB647@.microsoft.com...
> We had a hard drive crash on one of our servers. There are no backups of
the
> database available but we were able to recover the MDF and LDf for the
only
> database that was on the server. The server had to be rebuilt and SQL
> reinstalled. The question I have, is there a way to recover this database
> using the MDF and LDF files. I tried using the sp_attach_db command but
> without much success (don't know if I used the wrong parameters or what).
Any
> suggestions would be greatly appreciated.

Database Recovery

I am having only mdf file and log file which is one week older .how can i restore the database.Is it possible to
restore the databaseIf you are lucky...
You can try sp_attach_single_file_db to attach the mdf file, but it is only
documented to work if you detached the database in the first place.
The log file is not usable in any way (as it is older than the database
file).
--
Tibor Karaszi, SQL Server MVP
Archive at:
http://groups.google.com/groups?oi=djq&as_ugroup=microsoft.public.sqlserver
"saravana" <saravana@.winsarinfo.com> wrote in message
news:CE22770B-A188-434A-9C4A-154DDED589F0@.microsoft.com...
> I am having only mdf file and log file which is one week older .how can i
restore the database.Is it possible to
> restore the database
>

Sunday, February 19, 2012

Database question

Hello

I am using visual Basic 2005 express.

The program I am working on uses a database called DMGCollectionDatabase.mdf which will be held locally on the computer the program is installed on

When I publish my program as a cddvd install I get a setup file some other files and in the datasets folder I get a DMGCollectionDatabase.mdf.deploy file

if i install this program on a different computer than the one I used to build it it saves all the database information somewhere no clue where. what I need to be able to do is get the program to write to the DMGCollectionDatabase.mdf database so users can save this file with there information the dmg database will become portable my whole issue is how do I make this happen (I read one post that mentioned just using the .exe file and the database file in a folder this currently gives me an error)

If anyone could please assist me in this problem I would be greatly appriciative I am sorry if I seem a bit slow I am a self learner with visual Basic 2005 express I am about 3 months into things using vb2005 step by step and online help as references.

Hi Warren,

The issue is that SQL Server doesn't care what the *.mdf/*.ldf files are called, and by themselves, these files are worthless (unlike MSAccess)

What your setup will need to do is:

1. Verify that the target has a version of SQL Server installed

2. Create the DMGCollectionDatabase if it doens't already exist on the target sql instance, using the *.mdf & *.ldf file you mentioned. You do this via the sp_attach_db procedure. So, if your setup deploys the DMGCollectionDatabase.mdf and DMGCollectionDatabase.ldf file to C:\SomeApp\DMGCollectionDatabase.mdf, you would issue the following command on the target sql server instance:

exec sp_attach_db @.dbname = 'DMGCollectionDatabase', @.filename1 = 'C:\SomeApp\DMGCollectionDatabase.mdf', @.filename2 = 'C:\SomeApp\DMGCollectionDatabase.ldf'

And away you go...

Cheers,

Rob

|||

When I put this code into my formmain load "exec" gives me a declaration expected.

I placed the code above the first public class

|||

Hi Warren,

The code exec sp_attach_db @.dbname = 'DMGCollectionDatabase', @.filename1 = 'C:\SomeApp\DMGCollectionDatabase.mdf', @.filename2 = 'C:\SomeApp\DMGCollectionDatabase.ldf' is executing an SQL Server stored procedure - it needs to be executed against an sql server instance. Most setup/deployment tools allow you to shell a command, but if you're trying to do this from within VB, then you can execute the command in the context of a valid ado connection obejct, use dmo/smo or shell the command via osql.exe:

osql -E -i "exec sp_attach... etc"

For all available switches, have a look at osql in BOL. If you're using SQL2005, you should use the sqlcmd utility instead.

Cheers,

Rob