Overview
I recently conducted some tests to double check the exact behavior of database snapshots when:
Here is my testing methodology and the customary summary of observations.
Scenario
Test Case A: Can we create a snapshot on volume smaller than the database size?
If you are curious as to what I mean by 'size on disk', please refer to this snapshot:
It is a property of the NTFS sparse file that the actual space occupied on disk is much lesser initially than the 'Size' which is displayed for that file in Explorer.
Test Case B: Metadata-only operations and snapshot files
How is this possible? It turns out that certain operations such as TRUNCATE TABLE, DROP TABLE etc. directly operate on the IAM chain and possibly other internal allocation pages to efficiently 'clean up' data and metadata. In such cases the copy-on-write to the snapshot is deferred till such time that the actual data page and extent are touched.
Test Case 3: What effect does failure to write to the snapshot have on the main database?
Msg 5128, Level 17, State 2, Line 1 Write to sparse file 't:\Data\testss_1.ss' failed due to lack of disk space. Msg 5128, Level 17, State 2, Line 1 Write to sparse file 't:\Data\testss_1.ss' failed due to lack of disk space. Msg 5128, Level 17, State 2, Line 1 Write to sparse file 't:\Data\testss_1.ss' failed due to lack of disk space.
Msg 5128, Level 17, State 2, Line 1
Write to sparse file 't:\Data\testss_1.ss' failed due to lack of disk space.
Though, interestingly the main DELETE did not fail; all rows from the table T1 have been deleted. It is by-design that any failures to write to the snapshot are not going to affect the primary operation on the database.
Summary
So in conclusion this is what we can learn from the above. Most of it is logical when you think about it, but it is better to be sure than to guess!
Additional Reading