SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


MSDB Job History Tables


MSDB Job History Tables

Author
Message
A Little Help Please
A Little Help Please
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1038 Visits: 718
I have a number of instances on the same DB Server.
I can see that each DB has job related tables within the the MSDB DB.

I would like to create ONE central Table that stores all the DB job information.

i.e.
Table = CentralJobData
This should import yesterdays data from MSDB tables:
sysjobservers
sysjobs

For all the instances on the local server

Can this be done?
Any ideas how?
Mohit K. Gupta
Mohit K. Gupta
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3196 Visits: 1089
You can use linked servers to poll information from all the servers.

Create you new CentralJobHistory table on server of your choice. (S1)
Create a new login on each of the instances that has read permissions to the history table. (S2..Sn)
Create linked server between S1 and S2..Sn.
Create a job that imports data from S2.msdn.dbo.sysjobhistory to S1.db.dbo.CentralJobHistory.

... Thanks.

Mohit.

---

Mohit K. Gupta, MCITP: Database Administrator (2005), My Blog, Twitter: @SQLCAN.
Microsoft FTE - SQL Server PFE

* Some time its the search that counts, not the finding...
* I didn't think so, but if I was wrong, I was wrong. I'd rather do something, and make a mistake than be frightened and be doing nothing. Smooooth


How to ask for help .. Read Best Practices here.
EvilPostIT
EvilPostIT
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1094 Visits: 648
One option would be to create linked servers and then to create a view where you could do a union all to link tables together.

Create a linked server:
sp_addlinkedserver
@server='Target1',
@srvproduct='',
@provider='SQLNCLI',
@datasrc='SERVER'



Create a view to use the linked server:

CREATE VIEW vw_AllJobHistory
AS
select * from target1.msdb.dbo.sysjobs sj
inner join target1.msdb.dbo.sysjobhistory sjh on sj.job_id=sjh.job_id
union all
select * from target2.msdb.dbo.sysjobs sj
inner join target2.msdb.dbo.sysjobhistory sjh on sj.job_id=sjh.job_id
GO



.... Looks like i have been beaten to it ....Blush



Nuke the site from orbit, its the only way to be sure... w00t
A Little Help Please
A Little Help Please
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1038 Visits: 718
Brilliant guys!!!

Let me try!!
Il be back ;-)
A Little Help Please
A Little Help Please
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1038 Visits: 718
DONE - Create you new CentralJobHistory table on server of your choice. (S1)

DONE - Create a new login on each of the instances that has read permissions to the history table. (S2..Sn)

DONE - Create linked server between S1 and S2..Sn.

HELPCreate a job that imports data from S2.msdn.dbo.sysjobhistory to S1.db.dbo.CentralJobHistory.

Do I use type: T_SQL Script?
How whould I do the import?

Thanks
EvilPostIT
EvilPostIT
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1094 Visits: 648
Do you want to import on a scheduled basis or do you just want to link and then create a view which shows everything dynamically in real time?



Nuke the site from orbit, its the only way to be sure... w00t
A Little Help Please
A Little Help Please
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1038 Visits: 718
I want to import on a scheduled, and it should ONLY import:
"WHERE trade_date >= '2009-03-18'
EvilPostIT
EvilPostIT
Ten Centuries
Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)Ten Centuries (1.1K reputation)

Group: General Forum Members
Points: 1094 Visits: 648
Create the table structure


select sj.name,sjh.* into [CentralHistoryTable] from msdb..sysjobs sj
inner join msdb..sysjobhistory sjh on sj.job_id=sjh.job_id
where 1=0



For each server you want to pull data from (Though this will initially import all data and then only missing data)

insert into [CentralHistoryTable]
select sj.name,sjh.* from [linkname].msdb.dbo.sysjobs sj
inner join [linkname].msdb.dbo.sysjobhistory sjh on sj.job_id=sjh.job_id
full outer join [CentralHistoryTable] hist on hist.server=sjh.server and sjh.instance_id=hist.instance_id
where hist.name is null



Though you should put a clustered index on the table. Maybe something like this.


create clustered index CLX_HistoryTable on [CentralHistoryTable](run_date,run_time)



and maybe an index on the search fields


create index IX_HistoryTable on [CentralHistoryTable](server,instance_id)





Nuke the site from orbit, its the only way to be sure... w00t
vaidyanathan.kalyanasundaram
vaidyanathan.kalyanasundaram
Grasshopper
Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)Grasshopper (15 reputation)

Group: General Forum Members
Points: 15 Visits: 27
what if there are conflicting JOB IDs when we insert from each instance into the centraljobHistory table?
Bhuvnesh
Bhuvnesh
SSChampion
SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)SSChampion (13K reputation)

Group: General Forum Members
Points: 13438 Visits: 4077
If this happens, put a ID int identity column and set composite key on job_id and ID.
then you can go for Clus. Index

-------Bhuvnesh----------
I work only to learn Sql Server...though my company pays me for getting their stuff done;-)
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search