Thursday, July 5, 2012

Find all the database information from sys.databases

To find out  the database information

SELECT name ,database_id,create_date,compatibility_level,collation_name,user_access,is_read_only,is_auto_close_on,is_auto_shrink_on,state,state_desc,recovery_model,recovery_model_desc,page_verify_option,page_verify_option_desc,is_auto_create_stats_on,is_auto_update_stats_on
FROM sys.databases

Query for finding the SQL server information

select
serverproperty('Edition') EDITION,
serverproperty('ComputerNamePhysicalNetBIOS') 'COMPUTER NAME',
serverproperty('InstanceName') 'INSTANCE NAME',
serverproperty('IsClustered') 'IS CLUSTERED',
serverproperty('MachineName') 'Machine name',
serverproperty('ProductVersion') 'SQLPRODUCT VERSION',
serverproperty('ProductLevel') 'PRODUCT LEVEL',
serverproperty('ServerName') 'Server Name'
GO

Finding Job and owner details of Scheduled jobs in MSDB database



select sj.name,sj.description,suser_sname(sj.owner_sid) 'Job Owner',sj.enabled,sj.date_created,sj.date_modified,
sjs.next_run_date,sjs.next_run_time from msdb..sysjobs sj join
msdb..sysjobschedules sjs on sj.job_id=sjs.job_id
order by sj.name
..

Above query will return the job name, owner name, and some important information needed for the user..

Hope it gets useful..

SQL Server DBA Checklists ( Daily, Weekly & Monthly )

Daily

    Check system uptime (just in case I need to check anything as a DBA)
    Check the last backup
    Check the transaction log backups
    Check the status of SQL Jobs
    Check the average CPU usage for the last 24 hours (or 1140 mins)
    Check the database status
    Check the SQL error log and event viewer

Weekly

    Check MSDB backup history
    Check to see when the last time CheckDB and Update stats was run
    Check index fragmentation
    Check index stats (reads vs writes etc)
    Check for IO bottlenecks

Monthly

    Check missing indexes
    Check indexes that are no longer used
    Estimate the Disk usage by MDF file growing

****************************************************************************
 DAILY CHECK LIST:

    Backups
        Check for backup emails
        How long did the backup take to run (database backup duration)
        Verify that all databases are being backed up according to a maintenance plan
    Disk free space. Note significant variations from previous check. Log files may be affected dramatically by monthly jobs
   
Job failures. Filter job activity for failures
   
System checks. Look in sql logs for any critical errors.
        Application logs
    Performance
        Check performance statistics on all servers
        Check that counters are in normal range on all production servers
    Connectivity
        Verify the customer application can get data from the database
        Verify acceptable speed of access data
    Replication. Verify that the each publication and distributor is running for each subscription.
    Logshipping :Check the all jobs which should be run on as per the scheduled and check the availability space drives which is residing the T-log backup files.

    Mirroring : check the stats of mirroring.

Installing the Service Pack and Hot Fixes on SQL2005 Cluster

Once you have installed SQL Server 2005 clustering, your next step is to install the latest SQL Server 2005 service pack and hot fixes, which can be downloaded from Microsoft’s Web site. Installing a service pack or hot fix is fairly straightforward because they are cluster-aware. Once the service pack or hot fix setup program is started, it detects that you have a cluster and will upgrade all nodes simultaneously. Once setup is complete, you may need to reboot your servers and failover the nodes. Generally, once I have run the service pack, I like to reboot the active node first. Once it has rebooted, then I reboot the passive node. This way, failover and failback is automatic.