Script for below requests

  • Need scripts for below request:
    a)Find the new databases created last 24hrs.
    b) Find SQL servers uptime last 24hrs.
    3) Job failures for particular job in last 24hrs.

     Will be running the above requested queries in central management servers to get info across all servers. 

  • psred - Thursday, April 6, 2017 1:28 PM

    Need scripts for below request:
    a)Find the new databases created last 24hrs.
    b) Find SQL servers uptime last 24hrs.
    3) Job failures for particular job in last 24hrs.

     Will be running the above requested queries in central management servers to get info across all servers. 

    So, basically, you're asking people on this forum to do all of your work for you, without you providing any indication that you have even tried?

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • i'll help with the slightly more difficult one(#2)
    for number 1, sys.databases has a create_date column.

    for #2, i put this together, and it returns serveruptime, vs service uptime.
    select
    DATEADD(second, -1 * ( ms_ticks / 1000),getdate()) as ServerRestartTime,
    i.sqlserver_start_time As ServiceRestartTime,
    DATEDIFF(dd,i.sqlserver_start_time,GETDATE()) AS ServiceUpTimeInDays,
      DATEDIFF(dd,DATEADD(second, -1 * ( ms_ticks / 1000),getdate()),GETDATE()) AS ServerUpTimeInDays
    from sys.dm_os_sys_info i;

    for #3, there's plenty of searchable examples for failed jobs...search the submitted scripts section here for a huge array of examples

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply