How to see old job execution result logs from ldf file? [duplicate] - sql-server

This question already has answers here:
How can I view full SQL Job History?
(4 answers)
Closed last year.
In the Agent job view history of SQL Server, there are just limited log rows of o executed job. I want to see old executed job logs. Is there any way to see that?

Is there any way to see that?
Job history is stored in MSDB, so on test server restore an old backup of MSDB.

Related

SQL Server database restore question : how to restore database backup but merge with current data?

I need to restore a database to about 2 weeks back, I have nightly backups of the database. However I'm trying to avoid losing the data between now and 2 weeks ago.
If I restore the database to 2 weeks ago, will I lose all the data between then and today?
Is there a proper way to do this, or can I just use task>restore and pick my timeline?
Thanks all
You can restore the backup to a different database, and then merge the newer data into the restored database.

Rollback Update Operation in SQL Server

I executed an UPDATE operation for every row in my table by mistake. Is there any way I can take this back? I use SQL Server 2005.
I recently ran into same situation but latter used this third party tool and it worked !
http://www.apexsql.com/sql_tools_log.aspx
Read this thread it might help
And..
If you have already executed the update query and want to roll back,your only real option is to restore a database backup.
If you are using Full backups, then you should be able to restore the database to a specific point in time.

When you back up a database and scripts are running at the same time, at what point in time does the backup reflect? [closed]

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
If I run a SQL Server database backup via Management Studio and there are scripts running at the same time, does the backup reflect the point in time when the backup was started or when it ended? My db is about 10GB so the backup takes some time, meaning there's lots of things that could go on in the meantime.
I'm using SQL Server 2008 R2
Now I also asked in dba.
(Should this question just be removed/moved/what?)
A full backup includes the image of each allocated data page in the database and all the log that was generated from the moment the backup started until the backup finished all the data pages copy.
At restore time the data is copied out and the log is copied out and laid out on disk. If the RESTORE command was issued as WITH RECOVERY (default) then normal recovery is run on the database, meaning the log is replayed. This brings the database back into a consistent state. If the RESTORE was issued WITH NORECOVERY then the log and data are left 'as is' and the database can accept more log to be restored, copied out from other LOG backup(s) into the LDF file(s). Eventually, when the database is recovered, it is brought back into consistent state. See Restore and Recovery Overview (SQL Server).

how to force a stored procedure be pre-cached and stay in memory?

Stored procedures are compiled on first use.
There are options to clear cache:
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS
--To Verify whether the cache is emptied
--DBCC PROCCACHE
or to recompile or to reduce recompilations.
But is it possible to force frequently used stored procedures' execution plans be pre-cached and stay in memory?
I know how to do it in ADO.NET, i.e. from outside of SQL Server, but this question is how to do inside SQL Server - to be launched with the start of SQL Server itself.
(*) For example, I see in SSMS Activity Monitor a running process (Task State: RUNNING, Command: SELECT) that is continuously executing T-SQL (according to Profiler) in context of tempdb database though SQL Server Agent is disabled and SQL Server is not loaded by anything, see "Details of session 54" in "Where are all those SQL Server sessions from?".
How would I do the similar resident process (or, rather, auto-starting by SQL Server start service or session) periodically recycling stored procedure?
Related question:
Stored procedure executes slowly on first run
Update:
Might be I should have forked this question in 2 but my main curiosity is how to have periodic/ looping activity with SQL Server Agent disabled?
How was it made with mentioned above RUNNING SELECT session (*)?
Update2:
Frequently I observe considerable delays while executing stored procedures querying very small amount of data which cannot be explained only through necessity to read huge amounts of data.
Can we consider this - considerable delays on insignificantly small data - as context of this question?
Just execute it from a script. You could do this after any sql server restart. If they are frequently used, it shouldn't be much of a problem after that.
Seems like this question eventually got answered in:
Can I get SQL Server to call a stored proc every n seconds?
Update: These tips will do the trick:
Keeping data available in the SQL Server data cache with PINTABLE
Automatically Running Stored Procedures at SQL Server Startup

How can I tell if a SQL Server database is being backed up

Is there a way to programmatically determine if a SQL Server backup is currently being performd on a particular database?
We have automated database backup scripts for both data and log files, where the databases are backed up nightly and log files are backed up every 15 minutes, 24 hours a day. However, we think that the log file backup job is failing if it runs the same time as the full backup is being run.
What I'd like to do is to make a change to my transaction log script to not run a transaction log backup while the full backup is being run.
If there a DMV or a system table that I can query and work this out?
Yes there is
select * from sys.dm_exec_requests
where command = 'backup db'
and database_id = 6 --or whatever your db id is
Yes, it can be a problem in SQL 2000. Should not be a problem in 2005+
See this ServerFault question for the reason it conflicts.
See this Serverfault question for a more sophisticated script.

Resources