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

Thursday, March 22, 2012

Backing Up A MDF

I plan on using a database file for my site, how would I back it up if I were to make changes to my site?

From the sql server management studio, you can choose a backup option from the menus. Right-click on the database entry, choose Tasks, then Backup.

You can restore it using the Restore command.

Alternatively, you can Detach the database file, make a copy using windows, then reattach.

|||

Can this be done on my site, if I use ftp, can I download the file?

|||

Are you using a hosting provider? If you are, you will probably have to use their backup utility.

Once you use it, it will build a file that you should be able to ftp.

|||

Using SQL DMO for automated Database Backup and Restore.

Or,

This code may help you:

public static void BackupDatabase() {string sConnect = Properties.Settings.Default.BackupConnectionString;string dbName;using (SqlConnection cnn =new SqlConnection(sConnect)) { cnn.Open(); dbName = cnn.Database.ToString(); ServerConnection sc =new ServerConnection(cnn); Server sv =new Server(sc);// Check that I'm connected to the user instance Console.WriteLine(sv.InstanceName.ToString());// Create backup device item for the backup BackupDeviceItem bdi =new BackupDeviceItem(@."C:\AppDataBackup\SampleBackup.bak", DeviceType.File);// Create the backup informaton Backup bk =new Backup(); bk.Devices.Add(bdi); bk.Action = BackupActionType.Database; bk.BackupSetDescription ="SQL Express is a great product!"; bk.BackupSetName ="SampleBackupSet"; bk.Database = dbName; bk.ExpirationDate =new DateTime(2007, 5, 1); bk.LogTruncation = BackupTruncateLogType.Truncate;// Run the backup bk.SqlBackup(sv); Console.WriteLine("Your backup is complete."); } }
|||

Sql server comes with the capability to do a batch job, so you can just tell it to run the backup program without having to write a program...

Backing up a database that was been moved from another server

HI all
I have a database where we have moved the mdf/ldf files to another
server and reattached the database on the new server
I am now trying to backup this database up, but the wizard tell you
the backup has complete but it is too quick for it to be valid as the
db is 2gb
I also always get a message telling me 'The connection to the SQL
Server is broken' Do you want to try recoonecting to it
Any help?
Well ,try to restore your backup with a different name and you will get an
error message if the backup file is corrupted.
<satshergill@.yahoo.co.uk> wrote in message
news:1137407538.287495.195210@.g14g2000cwa.googlegr oups.com...
> HI all
> I have a database where we have moved the mdf/ldf files to another
> server and reattached the database on the new server
>
> I am now trying to backup this database up, but the wizard tell you
> the backup has complete but it is too quick for it to be valid as the
> db is 2gb
> I also always get a message telling me 'The connection to the SQL
> Server is broken' Do you want to try recoonecting to it
> Any help?
>

Backing up a database that was been moved from another server

HI all
I have a database where we have moved the mdf/ldf files to another
server and reattached the database on the new server
I am now trying to backup this database up, but the wizard tell you
the backup has complete but it is too quick for it to be valid as the
db is 2gb
I also always get a message telling me 'The connection to the SQL
Server is broken' Do you want to try recoonecting to it
Any help?Well ,try to restore your backup with a different name and you will get an
error message if the backup file is corrupted.
<satshergill@.yahoo.co.uk> wrote in message
news:1137407538.287495.195210@.g14g2000cwa.googlegroups.com...
> HI all
> I have a database where we have moved the mdf/ldf files to another
> server and reattached the database on the new server
>
> I am now trying to backup this database up, but the wizard tell you
> the backup has complete but it is too quick for it to be valid as the
> db is 2gb
> I also always get a message telling me 'The connection to the SQL
> Server is broken' Do you want to try recoonecting to it
> Any help?
>

Backing up a database that was been moved from another server

HI all
I have a database where we have moved the mdf/ldf files to another
server and reattached the database on the new server
I am now trying to backup this database up, but the wizard tell you
the backup has complete but it is too quick for it to be valid as the
db is 2gb
I also always get a message telling me 'The connection to the SQL
Server is broken' Do you want to try recoonecting to it
Any help?Well ,try to restore your backup with a different name and you will get an
error message if the backup file is corrupted.
<satshergill@.yahoo.co.uk> wrote in message
news:1137407538.287495.195210@.g14g2000cwa.googlegroups.com...
> HI all
> I have a database where we have moved the mdf/ldf files to another
> server and reattached the database on the new server
>
> I am now trying to backup this database up, but the wizard tell you
> the backup has complete but it is too quick for it to be valid as the
> db is 2gb
> I also always get a message telling me 'The connection to the SQL
> Server is broken' Do you want to try recoonecting to it
> Any help?
>sql

Tuesday, March 20, 2012

Backing up .mdf and .ldf files

I want to copy and paste .mdf and .ldf from our SQL server.
Am I correct in saying that the mdf and ldf files are locked into th SQL
databases and require the files to be detached via Enterprise Manager (for
SQL2000)?
In which case, how do I copy the .mdf and .ldf files to another HDD?
Is there a Utility I can use or another way?
Please help.
skc
Lookup sp_detach_db ,sp_attach_db in the BOL.
You can stop your services and copy/paste the files. I prefer
BACKUP/RESTORE operations
"Skc" <Skc@.discussions.microsoft.com> wrote in message
news:D6D5728B-1FEC-44AD-80DA-D93293D8CA4B@.microsoft.com...
>I want to copy and paste .mdf and .ldf from our SQL server.
> Am I correct in saying that the mdf and ldf files are locked into th SQL
> databases and require the files to be detached via Enterprise Manager (for
> SQL2000)?
> In which case, how do I copy the .mdf and .ldf files to another HDD?
> Is there a Utility I can use or another way?
> Please help.
> skc
|||Skc wrote:
> I want to copy and paste .mdf and .ldf from our SQL server.
> Am I correct in saying that the mdf and ldf files are locked into th SQL
> databases and require the files to be detached via Enterprise Manager (for
> SQL2000)?
> In which case, how do I copy the .mdf and .ldf files to another HDD?
> Is there a Utility I can use or another way?
> Please help.
> skc
Hi
Why do you want to copy the files rather than using Backup/Restore? If
you want to copy the database files, you'll have to detach them first
using sp_detach_db. You can now copy them as regular files and you can
then use sp_attach_Db to create the database when you've copied the
files to the new server.
Please keep in mind that your database will be unavailable when you run
sp_detach_Db and then until you attach it again with sp_attach_db.
You should also keep in mind, that after you've run the sp_detach_db you
haven't got a working database - not even the original. By this I mean
that if something goes wrong during the detach and the database file get
corrupted, you have lost your database. I know that it's not very likely
that it fails and if it eventually does, you might be able to recover it
in some way, but it's a potential risk.
If you go the backup route, you'll still have your original database
even though your backup doesn't work, so you can always create a new backup.
HTH
Regards
Steen

Backing up .mdf and .ldf files

I want to copy and paste .mdf and .ldf from our SQL server.
Am I correct in saying that the mdf and ldf files are locked into th SQL
databases and require the files to be detached via Enterprise Manager (for
SQL2000)?
In which case, how do I copy the .mdf and .ldf files to another HDD?
Is there a Utility I can use or another way?
Please help.
skcLookup sp_detach_db ,sp_attach_db in the BOL.
You can stop your services and copy/paste the files. I prefer
BACKUP/RESTORE operations
"Skc" <Skc@.discussions.microsoft.com> wrote in message
news:D6D5728B-1FEC-44AD-80DA-D93293D8CA4B@.microsoft.com...
>I want to copy and paste .mdf and .ldf from our SQL server.
> Am I correct in saying that the mdf and ldf files are locked into th SQL
> databases and require the files to be detached via Enterprise Manager (for
> SQL2000)?
> In which case, how do I copy the .mdf and .ldf files to another HDD?
> Is there a Utility I can use or another way?
> Please help.
> skc|||Skc wrote:
> I want to copy and paste .mdf and .ldf from our SQL server.
> Am I correct in saying that the mdf and ldf files are locked into th SQL
> databases and require the files to be detached via Enterprise Manager (for
> SQL2000)?
> In which case, how do I copy the .mdf and .ldf files to another HDD?
> Is there a Utility I can use or another way?
> Please help.
> skc
Hi
Why do you want to copy the files rather than using Backup/Restore? If
you want to copy the database files, you'll have to detach them first
using sp_detach_db. You can now copy them as regular files and you can
then use sp_attach_Db to create the database when you've copied the
files to the new server.
Please keep in mind that your database will be unavailable when you run
sp_detach_Db and then until you attach it again with sp_attach_db.
You should also keep in mind, that after you've run the sp_detach_db you
haven't got a working database - not even the original. By this I mean
that if something goes wrong during the detach and the database file get
corrupted, you have lost your database. I know that it's not very likely
that it fails and if it eventually does, you might be able to recover it
in some way, but it's a potential risk.
If you go the backup route, you'll still have your original database
even though your backup doesn't work, so you can always create a new backup.
HTH
Regards
Steensql

Backing up .mdf and .ldf files

I want to copy and paste .mdf and .ldf from our SQL server.
Am I correct in saying that the mdf and ldf files are locked into th SQL
databases and require the files to be detached via Enterprise Manager (for
SQL2000)?
In which case, how do I copy the .mdf and .ldf files to another HDD?
Is there a Utility I can use or another way?
Please help.
skcLookup sp_detach_db ,sp_attach_db in the BOL.
You can stop your services and copy/paste the files. I prefer
BACKUP/RESTORE operations
"Skc" <Skc@.discussions.microsoft.com> wrote in message
news:D6D5728B-1FEC-44AD-80DA-D93293D8CA4B@.microsoft.com...
>I want to copy and paste .mdf and .ldf from our SQL server.
> Am I correct in saying that the mdf and ldf files are locked into th SQL
> databases and require the files to be detached via Enterprise Manager (for
> SQL2000)?
> In which case, how do I copy the .mdf and .ldf files to another HDD?
> Is there a Utility I can use or another way?
> Please help.
> skc|||Skc wrote:
> I want to copy and paste .mdf and .ldf from our SQL server.
> Am I correct in saying that the mdf and ldf files are locked into th SQL
> databases and require the files to be detached via Enterprise Manager (for
> SQL2000)?
> In which case, how do I copy the .mdf and .ldf files to another HDD?
> Is there a Utility I can use or another way?
> Please help.
> skc
Hi
Why do you want to copy the files rather than using Backup/Restore? If
you want to copy the database files, you'll have to detach them first
using sp_detach_db. You can now copy them as regular files and you can
then use sp_attach_Db to create the database when you've copied the
files to the new server.
Please keep in mind that your database will be unavailable when you run
sp_detach_Db and then until you attach it again with sp_attach_db.
You should also keep in mind, that after you've run the sp_detach_db you
haven't got a working database - not even the original. By this I mean
that if something goes wrong during the detach and the database file get
corrupted, you have lost your database. I know that it's not very likely
that it fails and if it eventually does, you might be able to recover it
in some way, but it's a potential risk.
If you go the backup route, you'll still have your original database
even though your backup doesn't work, so you can always create a new backup.
HTH
Regards
Steen

Friday, February 10, 2012

Autonumber question

Does anyone know how to reset an autonumber field in SQLExpress 2005?

In MSAccess it was a simple "compress" of the database. My .mdf files are getting very large and I would like to shrink them down for easier mobility. A blank database takes up aprox. 30 mbs. Most all of the autonumber fields are currently in the 200,000 - 800,000 range. When I compressed my Access database prior to transfering to SQLExpress it significantly decreased the size of the empty database file.

Thank you for any help you can provide.

hi,

please have a look at http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=769553&SiteID=1

regards