Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I accidently executed TRUNCATE command on a wrong table and all my data is gone. We do have a backup but its 2 weeks old and doesn’t have all the latest data.
Any ideas how can we rollback this command and get the data back if possible? Are there any third party tools that can do this?
Simple answer is – you can’t rollback a transaction if it’s already committed but you can do something else to get the data back (or at least some parts of it).
When you execute truncate statement your data is still in the MDF file but it’s not visible because SQL Server is now treating this as free space (truncate is basically telling SQL Server to deallocate data pages).
Only way to get the data back is to somehow read deallocated data pages and convert them into readable data.
Important: you must act fast because free space will be overwritten with new data if not already. If you can stop your SQL Server instance and make a copy of MDF and LDF files that would buy you more time.
Try using ApexSQL Recover. From what I know it’s the only available tool that can do this kind of restore. If you’re really good with SQL you can try modifying and executing very long script like this .
Unless it was Transaction Wrapped, I am afraid you are out of luck.
Here is a similar post, but this also has more explanations.
http://www.sql-server-performance.com/forum/threads/how-to-rollback-truncate-operation.16968/
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 8 years ago.
Improve this question
I test bulk insert daily on my table for an ongoing project, the bulk files are around 1200000 records per day.
The transaction log keeps on increasing. I shirked my transaction log once which was of 9 gb, no backup has yet been taken.
Is it wise to shrink the transaction log like this.
Can I shrink the log after a full backup or need to back up the log separately?
Thanks
Here is great link, this is a summary of the info:
How do you clear the SQL Server transaction log?
Some things you don't want to do
Back up the log with TRUNCATE_ONLY option and then SHRINKFILE. For one, this TRUNCATE_ONLY option has been deprecated and is no longer available in current versions of SQL Server. Second, if you are in FULL recovery model, this will destroy your log chain and require a new, full backup.
Detach the database, delete the log file, and re-attach. I can't emphasize how dangerous this can be. Your database may not come back up, it may come up as suspect, you may have to revert to a backup (if you have one), etc. etc.
Use the "shrink database" option. DBCC SHRINKDATABASE and the maintenance plan option to do the same are bad ideas, especially if you really only need to resolve a log problem issue. Target the file you want to adjust and adjust it independently, using DBCC SHRINKFILE or ALTER DATABASE ... MODIFY FILE (examples above).
Shrink the log file to 1 MB. This looks tempting because, hey, SQL Server will let me do it in certain scenarios, and look at all the space it frees! Unless your database is read only (and it is, you should mark it as such using ALTER DATABASE), this will absolutely just lead to many unnecessary growth events, as the log has to accommodate current transactions regardless of the recovery model. What is the point of freeing up that space temporarily, just so SQL Server can take it back slowly and painfully?
Create a second log file. This will provide temporarily relief for the drive that has filled your disk, but this is like trying to fix a punctured lung with a band-aid. You should deal with the problematic log file directly instead of just adding another potential problem. Other than redirecting some transaction log activity to a different drive, a second log file really does nothing for you (unlike a second data file), since only one of the files can ever be used at a time. Paul Randal also explains why multiple log files can bite you later.
How do you clear the SQL Server transaction log?
Back up the transaction log (I assume the database is in full recovery) and then shrink file
DBCC SHRINKFILE (2, x)
(x is target size in MB)
Make sure to leave some free space in the file to avoid autogrowths.
You can also switch to simple recovery before shrinking if this didn't work as expected, and then switch back to full.
If the log continues to grow, check
select log_reuse_wait_desc from sys.databases
for the database in question.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
If the full backup is started at 11 and completed at 4. at 2.30 there are some transaction happened. Will it be reflected on this full back up file?
Check out these links from Paul Randal.
http://www.sqlskills.com/blogs/paul/a-sql-server-dba-myth-a-day-3030-backup-myths/
http://www.sqlskills.com/blogs/paul/debunking-a-couple-of-myths-around-full-database-backups/
http://www.sqlskills.com/blogs/paul/more-on-how-much-transaction-log-a-full-backup-includes/
Like many things in the database area, it all depends.
The last article is the best since it has the picture. If the database read operation completed after the transaction, then part of the log will be in the backup.
The best way to recover to 2:30 is to do a point in time restore.
Restore the backup, any log files, and use the STOP AT command to get to the exact time you want.
http://technet.microsoft.com/en-us/library/ms179451.aspx
Transactions are related to transaction log.
So after full backup , get a transaction log backup in order to be able restore database at a certain time.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm seeking for a solution to monitor (with graphs) the status of my MSSQL instances during a periode of time (day or night) and get or make reports for that monitoring.
Does any one have or know any known simple solutions to do so please ?
Thank you for your help.
Depends on what you want to monitor. There are vendor products that will do it. Idera has Diagnostic Manager and RedGate has SQL Monitor to name just a few. Or if you don't want to spend any money SQL Server has several monitoring options including alerts, policy based management and data collection. These won't be as pretty and may not cover as much not to mention you will be writing some code on your own, but they are free (with SQL Server of course, depending on edition).
Related, though you'll want to edit the scripts for getting information is Ola Hallengren's maintenance solutions http://ola.hallengren.com/. There are useful scripts for maintenance, but depending on what information you're trying to obtain, you can build on these scripts to get information. From there, you can use the results of these queries in SSRS to populate graphs, or even use a tool like Excel.
Again, Ola Hallengren provides maintenance solutions, so these will need to be adjusted for monitoring (depending on what you're monitoring), but they are totally free and you can edit the scripts, as well as see where the information comes from so that you can determine what you need to monitor.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I know that I can't get a specific answer to my question, but I would like to know if I can find the tools to get to my answer.
Ok we have a Sql Server 2008 database that for the last 4 days has had moments where for 5-20 minutes becomes unresponsive for specific queries.
e.g. The following queries run in different query windows simultaneously have the following results
SELECT * FROM Assignment --hangs indefinitely
SELECT * FROM Invoice -- works fine
Many of the tables have non-clustered indexes to help speed up SELECTs
Here's what I know:
1) The same query will either hang indefinitely or run normally.
2) In Activity Monitor in the processes tab there are normally around 80-100 processes running
I think that what's happening is
1) A user updates a table
2) This causes one or more indexes to get updated
3) Another user issues a select while the index is updating
Is there a way I can figure out why at a specific moment in time SQL Server is being unresponsive for a specific query?
The sp_who system stored procedure will tell you if a connection is blocked because of another query.
When a query (such as your examples) hangs, the most common cause (in my experience) is that another query is blocking it. This might be apparent.
To diagnose this, I simply uses Activity Monitor in Sql server Management Studio.
Find the node that is being blocked and through that, you can find what is causing the block. Then at least you isolate the problem. The next step is to prevent the blocking... That will certainly depend.
For me, it's been a long running BEGIN TRAN contents.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
What are the most memory consuming reasons in SQL SERVER 2005?
The SQL Rocks article Memory Use in SQL Server will probably answer your question.
I think this is one of the important parts:
SQL Server's caching behavior is the
reason for the substantial memory use.
This is by design and is not a bug,
memory leak nor incorrect
configuration. Every time
SQL Server needs to read a page from
disk it caches the page in memory so
that the slow disk operation will be
unnecessary should SQL Server need
that page again. Every time SQL Server
needs to read a page from disk it
caches the page in memory so that the
slow disk operation will be
unnecessary SQL Server should need
that page again.
SQL Server is just memory hungry. The more memory you give it, the more it will use. SQL Server should probably always be run on its own server if it is doing anything non-trivial. In other words, don't install SQL Server on your domain controller, file server or source control repository (unless your source control repository uses SQL Server).
Buffer pool for mainly data, plans, locks
Can you add some background please?