MS SQL SERVER BACKUP Issue - sql

In sql server 2008, i have taken Full backup type of my database and database was successfully done.My question is while restoring it how can i check or know that my whole backup was perfect ?

You can use RESTORE VERIFYONLY for that.

See Detecting and Coping with Media Errors During Backup and Restore

The DB won't come on-line if something is wrong most likely.
Although, you can run RESTORE VERIFYONLY, you're more likely to restore the wrong DB or from the wrong backup file to be honest.
If you want you could run DBCC CHECKDB.
I tend to query a known table for the last "updateddatetime" column

Related

How to recover deleted data from SQL server table? [duplicate]

I accidentaly ran a DELETE command against a table with a wrong WHERE
clause.
I am using SQL Server 2005.
Is there a way that could help me recover the lost data?
It is possible using Apex Recovery Tool,i have successfully recovered my table rows which i accidentally deleted
if you download the trial version it will recover only 10th row
check here http://www.apexsql.com/sql_tools_log.aspx
You have Full data + Transaction log backups, right? You can restore to another Database from backups and then sync the deleted rows back. Lots of work though...
(Have you looked at Redgate's SQL Log Rescue? Update: it's SQL Server 2000 only)
There is Log Explorer
I think thats impossible, sorry.
Thats why whenever running a delete or update you should always use BEGIN TRANSACTION, then COMMIT if successful or ROLLBACK if not.
What is gone is gone. The only protection I know of is regular backup.

How can I restore a database in SQL Server 2012 from SQL Server 2012 Express?

I am having problems to restore a database from SQL Server 2012 and SQL Server 2012 Express to my SQL Server 2012 where I need this db to do some tests.
When I select the .bak file it is nothing shown in the 'backup sets to restore' area below. This is the newest backup I have made.
Is there any way to make it happen? even settings that I must have to do?
I have read that there is impossible to restore from the a higher SQL Server version? Is that true?
Best Regards,
Weslley.
What do you see (if anything) when you run this command:
USE [master]
RESTORE HEADERONLY
FROM DISK = N'your-drive-and-path-to-the-backup-file.bak'
WITH NOUNLOAD;
GO
Does that show you anything? Does it cause an error? If so: what error?
Guys thanks very much for the help you gave.
I did not know that when I go to the button Help/About I was seeing the version of the SSMS and not of the DataBase..
So in both case i was trying to restore a database from a higher version, so it could not work properly.

If I restore a database and overwrite the original is there any way to go back? SQL Management Studio

I do not have a backup available but I wrote over an existing database with a backup file.
The problem is the one I wrote OVER had a Stored Proc that I need to get back. Any way to do this without a backup file of the database with the Stored Proc in it?
Basically the answer is no.
It might be worth looking in your %temp% directory though at the files entitled ~....sql just in case you are extraordinarily lucky.
I have SSMS toolspack installed and that keeps a log of all SQL statements executed in Management Studio which might have been useful in this instance.
Not unless you have a copy of the script that created the proc in the first place.

Restoring two databases from a single backup file (SQL Server 2005)

I have a .bak file which contains backup sets of two different databases. It was made by sql server maintenance plan. Now I have to restore both databases. The problem is, that while the first database is restored ok (db_companies) the other database (db_data) gives an error:
Restore failed for Server 'SBSERVER'.
(Microsoft.SqlServer.Smo)
System.Data.SqlClient.SqlError:
Logical file 'CompaniesDB'
is not part of database 'DataDB'. Use
RESTORE FILELISTONLY to list the
logical file names.
(Microsoft.SqlServer.Smo)
The database restore wizards shows up both databases, and I select full and the lastest differential sets. The RESTORE FILELIST command show only the CompaniesDB. What's up with this?
I've also tried RESTORE DATABASE WITH MOVE but it doesn't recognize the DataDB logical name.
Is there any way to restore the DataDB from the backup set?
After doing some intensive research, I finally found out that this is a bug in sql server 2005. After I installed the SP3 everything went fine.
1)If you (in Management Studio), detach db_data, back up the existing mdf and log, then delete database completely, making sure the mdf and log are gone from their original DATA folder.
2)Then, right click on databases and go to "Restore Database"
3)Choose the source first! Go to "From Device" and browse to the .MDF
4)Now expand the drop down list with the heading "To Database" under the "Destination for Restore" section and choose db_data.
5)Click OK
6)It should restore fine, right click on it, go to properties and set the owner.
Note, this is me using MSSQL 08 but if memory serves me right there wasnt a drastic difference in management studio for 05.
Im sure someone else here knows a cleaner way, but the above will work.
The bak file may not have the backup of both databases.
Depending on your setup, it's one backup per file unless the file is actually a "device" and the backup did not initiase the device/file.

Undo changes to SQL Server 2005 database

I've ran some "ALTER" scripts on the database [SQL Server Server 2005], and overwrote some sprocs. Is there any way to undo changes and get my old sprocs back?
Is there a way to get the scripts that were executed out of the .LDf file? That way i can re-run my initial "create" script for my sprocs.
I don't have a backup file with old sprocs.
p.s. i backed the DB up as per #Gulzar's deleted answer, and looks like I'm "hosed".
#Pittsburgh DBA: thanx for the solution, but it doesn't seem to work after the backup.
MORAL: Wait for 10 minutes before trying the suggested answers out
Update from Gulzar: What I meant was a file backup before trying anything (to be safe). Not a SQL Server backup.
FIRST: DO NOT TAKE ANY BACKUPS JUST YET.
There are several tools on the market to do this sort of thing.
You might try this one:
ApexSQL Log
In case anybody else has the same problem - Were you doing transaction log backups every X minutes? If so, you can use Quest LiteSpeed's log reader or Quest Toad for SQL Server's log reader to read the log file backups. It gives undo/redo scripts too for any transaction in the log backups or the ldf.
And after that, look into using ApexSQLScript to script out your databases on a regular basis (and store in version control).
yo do can!!
go to sql server managment studio,connect to your db, left click on your db and go to "tasks".
select restore -> database.
then click the "timeline" button and select 'especific date' and select the day before your mistake.
All programs that have access to your db mus be closed.
It worked for me, i had this very same probelm.