First and foremost, I am very brand new to databases so please keep instructions simple for me. thanks!
Usually when I need to make a manual change I just back up my SQL Server Management Studio 2012 database called Movies, then upload it to my host, then use their restore feature to implement it.
I am still in a testing phase so data does not need to be kept that is acquired online, however I wanted to try keeping the data today so I used the host's backup option which created a DB_76779_test_backup.bak file for me.
I then download this and "attempted" to updated it's information into the SQL database on my machine (Movie) which I believe is where I messed everything up.
From what I remember I right-clicked my database "Movies" and selected "Tasks -> Restore -> Database", I kept everything as is, but for Source I selected Device then chose the DB_76779_test_backup.bak file and and below that selected "Movies" as the Database and hit OK.
This seemed to work fine, so I opened and edited the tables values that needed to be changed. Then as usual, I just backed it up, ftp'ed it to the host, and restored my database.
I got an error however when trying to restore and my support told me the following.
"Logical file 'Movies' is not part of database 'DB_76779_test'. Use
RESTORE FILELISTONLY to list the logical file names."
I'm afraid we only support restores of databases that contain only 1
.mdf file and 1 .ldf file with no extra partitions.
I am assuming that since the only different thing I did this time was restore my database on my computer is that somehow I broke it, or created more than 1 mdf and ldf file (no clue what those even are). All I was trying to do was keep the actual data from online, so I am not even sure if that was correct way to go about this, but regardless I am unable to restore the database on my host now..
I am hoping someone here has instantly realized what idiotic mistake I made, because I only know a basic level of databasing and not much of the "under the hood" mechanics.
Let me know if you need further details.
That SSMS dialog is a little difficult to work with some times. It looks like you want to rename your database to Movies. The problem is when you change the name field it does not update the logical names it is using for the files. IIRC simply switching to the Files "tab" on the left will update it and then you can restore fine. That or do your restore with the "old" name and then name the database after restore.
Related
I detached a SQL Server database named company_content as I thought it was no longer needed but didn't want to delete it just yet.
Turns out I need it. When I tried to attach, I couldn't find company_content in the list. Apparently the database name doesn't match up with the .mdf name.
How can I find it?
Thanks,
Scott
Check the other MDF files where you would otherwise expect the database files to be stored, as it could have been saved under another name. If that doesn't turn up anything, you can try doing a search for any files on your system with an .MDF extension; perhaps it was simply saved somewhere a little out of the way (in which case, this would be a great opportunity to move it somewhere more reasonable).
I've not done much SQL and am still pretty new to this, so please excuse what's probably a basic question.
I've been asked to look into creating an SQL job to backup our databases, store the .baks on another machine and then to restore them to a second server. I've been doing a bit of research and playing with SSMS and have back-ed up the database to my personal machine by setting up a share and running a backup job to the share location. I'm now trying to create a new database (on the same server I back-ed up from) by restoring the .bak file (but giving the database I'm trying to create a new name and what-not) but am unable to specify restoring it from the share, like I did when backing it up/I can't find how to specify other network locations and am just browsing the server's C drive when I try to locate the file.
For now, I'm just using the built-in wizards to try and achieve this (open SSMS -> Connect to server -> right click DataBases -> Restore DataBases and then select From Device and browse to find the file).
This isn't the final process, just me trying to get to grips with how this works. As I said, the idea is to ultimately have a scheduled job to backup the DB from server1 to a .bak on, say, my personal machine and then to restore that to a DB on server2 (different network, different city) and, probably, with a series of SQL commands rather than using the wizard every time (there are a few DBs that'll, ultimately, need backing up).
My apologies for the, possibly, quite drawn out and convoluted question - essentially, all I need to know is can I/how can I restore a DB in SSMS from a .bak on a different machine?
Many thanks
You could use something like the following script. It restores a database from the filesystem, and it overwrites the existing database with the name of "MyDB", moving the files to new locations of your choice in the process.
RESTORE DATABASE
MyDB
FROM DISK = '\\MyShare\MyBackup.bak'
WITH
MOVE 'DataFile' TO 'D:\myNewDBLocation\DataFile.mdf',
MOVE 'LogFile' TO 'E:\\myNewDBLocation\LogFile.ldf'
, REPLACE
You can find out the name of the llogical files (in the above, those are called DataFile and LogFile by running the following:
RESTORE FILELISTONLY
FROM DISK = '\\MyShare\MyBackup.bak'
Additional information about various options and parameters:
RESTORE (Transact-SQL)
I have created an application in VB.NET (using Microsoft Visual Basic 2010 Express) with a local database (SQL Server Compact 3.5 database) to store data.
I have installed this on the users computer, and added a "search online for updates" functionallity (which can be selected when publishing)
Now i have noticed, that sometimes when i upload a new version, the data from the database gets cleared. (possibly when i opened the dtb while developing)
This is offcourse not how i want the system to behave, and the data should always remain on the users computer.
In 'Application Files' the database file (*.sdf) is currently set to 'Data File (Auto)', but i'm unsure of the exact way this works.
Could anyone help me to understand how all of this works, and tell me how i can be sure that the data in the users database will remain, even after an update?
If there is no solution to ensure this, is there a way to safely backup the data and reload it?
Thanks in advance!!
Basically, the click one install overwrites everything in the program folder that is included in your publish. So if you include the .sdf then it will overwrite it when the installer is executed. What you need to do is select "exclude" on the sdf instead. This will keep the database in its previous state.
So my recommendation would be to have 2 different publishes. One that you create that contains the .sdf which is only used on first time installation, and then in all the update ones you exclude it.
To perform updates on your tables you would have to write the SQL for it in your software. Basically do a check on all tables to see that they have the proper setup on startup. If they don't then you add the missing columns.
Hope this helps.
I am working with this error for sometime now.
"Failed with the operaring System Error 21 (The device is not ready.)"
I scourged the internet but could not find the solution. Here are the links that look at
I am using this tutorial for importing the database (.bak) while which was exported from another machine and copied to mine.
On this page the very last paragraph is very helpful but it did not work for me.
I looked for other links and tried their solution, those did not work either.
I changed directory permission and allowed full access to everyone, that did not work. I also copy that .bak files to the other back databases that I have (and which imports fine), that still did not work.
Am I missing something simple, permission etc?
I am using SQL Server 2005 with SQL Server Management Studio.
I assume this was a security feature.
I could not restore the database into a name other than its original name which I was trying to do. But I could restore back on the same system into a different name. What I did is back my current database and restored them in different names that I wanted.
Right click on the original database and click restore. In this case do not change the name of the database or any parameters, it should now work.
I would also be caution to allow everyone in the directy where the backups are copied and give *everyone" object full control of the folder.
Hope it helps.
This error is a warning that you're saving the file(s) into a location that doesn't exist on that particular SQL Server workstation. For instance, if you backup a database on one machine containing an "E:\SQL_Databases" folder, and then transfer the .bak file to a machine containing only one hard drive designated as "C:\". SQL Server "remembers" where the .mdf, .ldf. and .ndf files resided on the first machine and tries to restore them to the same place. So make sure the location to which you are restoring the .mdf, etc. actually exists on the new machine. If everything doesn't match exacty, you receive this error.
I simply copied my .mdf/.ldf files to another file and suddenly my Microsoft SQL 2008 database dies. I can't open these files on another system either. Can anyone explain what's happened? Any way to recover this application's database now?
Did you stop the service or detach the files first?
You are not supposed to copy files when the server is online.
if you want to copy when the server is online, you can right click on management studio , -> detach->
then copy the files to another instance , and choose attach on new server. remember you need to know the location of the files, before you detach, also you should be knowing, also the logins need to transfer.
Have you tried moving the database files back to where they were? (Specifically, stop SQL server, move files, start SQL Server).
Whenever I do this kind of work, I make copies of the files, and rename the original ones (from, say, MyData.mdf to xMyData.mdf). Makes it easier to back out when my fatfingers take over.