Home » CodeProject

Category Archives: CodeProject

2013 with You & SQL Server


The WordPress.com stats helper monkeys prepared a 2013 annual report for this blog.

Here’s an excerpt:

The concert hall at the Sydney Opera House holds 2,700 people. This blog was viewed about 41,000 times in 2013. If it were a concert at Sydney Opera House, it would take about 15 sold-out performances for that many people to see it.

Click here to see the complete report.

Database Snapshot failed due to disk space issue


Database snapshot is really a useful feature. As we know, Snapshot database file will keep increasing parallel to the DML operations on database. But if disk containing snapshot file run out of space then what will be the impact on new transactions, database & snapshot?

Microsoft design snapshot in very well manner. If Snapshot failed to records the data changed by DML transaction due to disk space issue then your snapshot will become unusable & reaches to suspect mode and on the other hand your actual database will keep running un-impacted.

Snapshot database cannot be recovered from suspect state so you need to drop & recreate the snapshot database.

1) While running below transaction, We got error that unable to write on snapshot file due to disk space issue.

2) We check data in table to check id transaction completed successfully or failed due to snapshot issue. We found transaction is completed & database is running fine.

3) After that, When we try to select snapshot database, We got error that database is suspect mode.

4) We also try to bring snapshot database in emergency mode to see if we can troubleshoot it but We got error that this operation can not be performed on snapshot database.

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Cumulative Update – 9 for SQL Server 2008 R2 Service Pack 2 Is Now Available !


The 9th cumulative update release for SQL Server 2008 R2 Service Pack 2 is now available for download at the Microsoft Support site. Cumulative Update 9 contains all the hotfixes released since the initial release of SQL Server 2008 R2 SP2.

Those who are facing severe issues with their environment, they can plan to test CU8 in test environment & then move to Production after satisfactory results.

To other, I suggest to wait for SP3 final release to deploy on your production environment, to have consolidate build.

KB Article For CU9 of SQL Server 2008 R2 SP2

· CU#9 KB Article: http://support.microsoft.com/kb/2887606

Previous Cumulative Update KB Articles:

· CU#8 KB Article: http://support.microsoft.com/kb/2871401

· CU#7 KB Article: http://support.microsoft.com/kb/2844090

· CU#6 KB Article: http://support.microsoft.com/kb/2830140

· CU#5 KB Article: http://support.microsoft.com/kb/2797460

· CU#4 KB Article: http://support.microsoft.com/kb/2777358

· CU#3 KB Article: http://support.microsoft.com/kb/2754552

· CU#2 KB Article: http://support.microsoft.com/kb/2740411

· CU#1 KB Article: http://support.microsoft.com/kb/2720425

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Cumulative Update – 10 for SQL Server 2012 RTM Is Now Available !


The 10th cumulative update release for SQL Server 2012 RTM is now available. Cumulative Update 10 contains all the hotfixes released since the initial release of SQL Server 2012 RTM.

Those who are facing severe issues with their environment, they can plan to test CU10 in test environment & then move to Production after satisfactory results.

KB Article For CU9 of SQL Server 2012

· CU#10 KB Article: http://support.microsoft.com/kb/2891666

Previous Cumulative Update KB Articles of SQL Server 2012

· CU#9 KB Article: http://support.microsoft.com/kb/2867319

· CU#8 KB Article: http://support.microsoft.com/kb/2844205

· CU#7 KB Article: http://support.microsoft.com/kb/2823247

· CU#6 KB Article: http://support.microsoft.com/kb/2728897

· CU#5 KB Article: http://support.microsoft.com/kb/2777772

· CU#4 KB Article: http://support.microsoft.com/kb/2758687

· CU#3 KB Article: http://support.microsoft.com/kb/2723749

· CU#2 KB Article: http://support.microsoft.com/kb/2703275

· CU#1 KB Article: http://support.microsoft.com/kb/2679368

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

DMV-15 : Pending I/O requests……..sys.dm_io_pending_io_requests


sys.dm_io_pending_io_requests DMV (Dynamic Management View), described by BOL as follows: http://msdn.microsoft.com/en-us/library/ms188762.aspx

Returns a row for each pending I/O request in SQL Server.

It’s a very simple DMV used to see all pending I/O requests & there description.

You can combine this DMV with DMF – sys.dm_io_virtual_file_stats to see I/O pending requests with database files. You should run this query multiple times to check if the same files or drive letters consistently coming up on the top. If this is the case that means you facing I/O bottlenecks for that file or drive letter.

Query 1 : Details of I/O pending requests against each DB file

SELECT

DB_NAME(MF.DATABASE_ID) AS [DATABASE],

MF.PHYSICAL_NAME,

IPIR.IO_TYPE,

SUM(IPIR.IO_PENDING) TOTAL_PENDING_IO,

SUM(IPIR.IO_PENDING_MS_TICKS) TOTAL_PENDING_MS_TICKS,

SUM(VFS.NUM_OF_READS) TOTAL_READS,

SUM(VFS.NUM_OF_WRITES) TOTAL_WRITES

FROM

SYS.DM_IO_PENDING_IO_REQUESTS AS IPIR

INNER JOIN

SYS.DM_IO_VIRTUAL_FILE_STATS(NULL,NULL) AS VFS

ON IPIR.IO_HANDLE = VFS.FILE_HANDLE

INNER JOIN

SYS.MASTER_FILES AS MF

ON VFS.DATABASE_ID = VFS.DATABASE_ID

AND VFS.FILE_ID = MF.FILE_ID

GROUP BY MF.DATABASE_ID, MF.PHYSICAL_NAME, IPIR.IO_TYPE

ORDER BY SUM(IPIR.IO_PENDING)

Remarks

1. To use this DMV, User required VIEW SERVER STATE permission on the server.

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Cumulative Update – 13 for SQL Server 2008 SP3 Is Now Available !


The 13th cumulative update release for SQL Server 2008 Service Pack 3 is now available. Cumulative Update 13 contains all the hotfixes released since the initial release of SQL Server 2008 SP3.

Those who are facing severe issues with their environment, they can plan to test CU13 in test environment & then move to Production after satisfactory results.

To other, I suggest to wait for SP4 final release to deploy on your production environment, to have consolidate build.

KB Article For CU13 of SQL Server 2008 SP3

§ CU#13 KB Article: http://support.microsoft.com/kb/2880350

Previous Cumulative Update KB Articles of SQL Server 2008 SP3:

§ CU#12 KB Article: http://support.microsoft.com/kb/2863205

§ CU#11 KB Article: http://support.microsoft.com/kb/2834048

§ CU#10 KB Article: http://support.microsoft.com/kb/2814783

§ CU#9 KB Article: http://support.microsoft.com/kb/2799883

§ CU#8 KB Article: http://support.microsoft.com/kb/2771833

§ CU#7 KB Article: http://support.microsoft.com/kb/2738350

§ CU#6 KB Article: http://support.microsoft.com/kb/2715953

§ CU#5 KB Article: http://support.microsoft.com/kb/2696626

§ CU#4 KB Article: http://support.microsoft.com/kb/2673383

§ CU#3 KB Article: http://support.microsoft.com/kb/2648098

§ CU#2 KB Article: http://support.microsoft.com/kb/2633143

§ CU#1 KB Article: http://support.microsoft.com/kb/2617146

If you liked this post, do like on facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Cumulative Update – 6 for SQL Server 2012 Service Pack 1 Is Now Available !


The 6th cumulative update release for SQL Server 2012 Service Pack 1 is now available. Cumulative Update 6 contains all the hotfixes released since the initial release of SQL Server 2012 SP1.

Those who are facing severe issues with their environment, they can plan to test CU6 in test environment & then move to Production after satisfactory results.

To other, I suggest to wait for SP2 final release to deploy on your production environment, to have consolidate build.

KB Article For CU6 of SQL Server 2012 SP1

§ CU#6 KB Article: http://support.microsoft.com/kb/2874879

Previous Cumulative Update KB Articles of SQL Server 2012 SP1

§ CU#5 KB Article: http://support.microsoft.com/kb/2861107

§ CU#4 KB Article: http://support.microsoft.com/kb/2833645

§ CU#3 KB Article: http://support.microsoft.com/kb/2812412

§ CU#2 KB Article: http://support.microsoft.com/kb/2790947

§ CU#1 KB Article: http://support.microsoft.com/kb/2765331

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

How to Check SQL Server Evaluation Version Expire Date ?


SQL Server Evaluation Edition is available free of cost. It’s a trial version & valid for limited time of period. The expiration date is always 180 days from the initial installation date.

The following query will give you the expiration date of evaluation instance :

SELECT

@@SERVERNAME SERVERNAME,

CREATE_DATE ‘INSTALALTIONDATE’,

SERVERPROPERTY(‘EDITION’) ‘Version’,

DATEADD(DD, 180, CREATE_DATE) AS ‘EXPIRY DATE’

FROM SYS.SERVER_PRINCIPALS

WHERE SID = 0X010100000000000512000000

SID 0X010100000000000512000000 is associated with login “NT AUTHORITYSYSTEM” & which is created at the time of installation only.

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

DMV-14 : Which Table has Max. rows & Size……..sys.dm_db_partition_stats


sys.dm_db_partition_stats DMV (Dynamic Management View), described by BOL as follows: http://msdn.microsoft.com/en-us/library/ms187737.aspx

Returns page and row-count information for every partition in the current database.

This DMV gives useful information about rowcount, free & reserved space of each table in database. It can be used for analysis purpose while adding new indexes, doing index Maintenance or checking the biggest table of database.

Query 1 : Details of table with row count & space used

SELECT

SS.NAME AS SCHEMANAME,

SO.NAME AS OBJECTNAME,

SI.NAME AS INDEXNAME,

PS.RESERVED_PAGE_COUNT*8 TOTAL_SPACE_CONSUMED_KB,

PS.USED_PAGE_COUNT*8 USED_SPACE_KB,

(PS.RESERVED_PAGE_COUNT – PS.USED_PAGE_COUNT)*8 FREE_SPACE_KB,

CASE

WHEN PS.INDEX_ID IN (0,1) THEN PS.ROW_COUNT

ELSE NULL

END AS ROW_COUNT

FROM

SYS.DM_DB_PARTITION_STATS PS

INNER JOIN SYS.OBJECTS SO ON SO.OBJECT_ID = PS.OBJECT_ID

INNER JOIN SYS.SCHEMAS SS ON SS.SCHEMA_ID = SO.SCHEMA_ID

LEFT JOIN SYS.INDEXES SI ON SI.OBJECT_ID = PS.OBJECT_ID

AND SI.INDEX_ID = PS.INDEX_ID

WHERE

SO.IS_MS_SHIPPED = 0

Sample Result

Remarks

1. To use this DMV, User required VIEW DATABASE STATE permission on the server.

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Cumulative Update – 8 for SQL Server 2008 R2 Service Pack 2 Is Now Available !


The 8th cumulative update release for SQL Server 2008 R2 Service Pack 2 is now available for download at the Microsoft Support site. Cumulative Update 8 contains all the hotfixes released since the initial release of SQL Server 2008 R2 SP2.

Those who are facing severe issues with their environment, they can plan to test CU8 in test environment & then move to Production after satisfactory results.

To other, I suggest to wait for SP3 final release to deploy on your production environment, to have consolidate build.

KB Article For CU5 of SQL Server 2008 R2 SP2

· CU#8 KB Article: http://support.microsoft.com/kb/2871401

Previous Cumulative Update KB Articles:

· CU#7 KB Article: http://support.microsoft.com/kb/2844090

· CU#6 KB Article: http://support.microsoft.com/kb/2830140

· CU#5 KB Article: http://support.microsoft.com/kb/2797460

· CU#4 KB Article: http://support.microsoft.com/kb/2777358

· CU#3 KB Article: http://support.microsoft.com/kb/2754552

· CU#2 KB Article: http://support.microsoft.com/kb/2740411

· CU#1 KB Article: http://support.microsoft.com/kb/2720425

If you liked this post, do like on Facebook at http://www.facebook.com/mssqlfun

Reference : Rohit Garg (http://mssqlfun.com/)

Follow

Get every new post delivered to your Inbox.

Join 130 other followers