Recently I encountered error 1803 when working on SQL Server 2012. The script I ran against a SQL Server 2012 instance was
CREATE DATABASE [suspect_db] ON PRIMARY
( NAME = N'suspect_db', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQL11_CTP3\MSSQL\DATA\suspect_db.mdf' , SIZE = 2048KB , FILEGROWTH = 1024KB )
LOG ON
( NAME = N'suspect_db_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQL11_CTP3\MSSQL\DATA\suspect_db_log.ldf' , SIZE = 1024KB , FILEGROWTH = 10%)
GO
I was confident I used this same script successfully on previous versions of SQL Server. Therefore, I examined the error message and the script properly:
Msg 1803, Level 16, State 1, Line 3
The CREATE DATABASE statement failed. The primary file must be at least 3 MB to accommodate a copy of the model database.
Then I went and compared the physical size of model and noticed that the size changed between SQL Server 2012 and previous versions. Here is a comparison of the sizes:
SQL Server version
Physical file size (bytes)
sp_spaceused information
model.mdf
modellog.ldf
reserved
data
index_size
unused
2000
655,360
524,288
528 KB
144 KB
280 KB
104 KB
2005
1,245,184
1136 KB
472 KB
560 KB
2008
1,310,720
1200 KB
624 KB
2008 R2
1216 KB
512 KB
632 KB
72 KB
2012
2,162,688
2096 KB
792 KB
1080 KB
224 KB
So, the next obvious question is - Why this change now?
When the SQL Server product team ships new features or enhancements to existing features, these involve changes to the core metadata. These might be in the form of new system tables, views, stored procedures and other objects. In some occasions, these changes may be server wide that you just make the change to the associated catalog tables in the msdb or master database. If this is a change that needs to be implemented in every database, then you will see the effect in the model database. Since we added several new exciting features in SQL Server 2012, we needed to add supporting system tables in every database. Therefore, those need to be persisted in model database first. Depending upon on the number of system tables you add and the available free space, the data file needs to grow. That is what happened in SQL 2012. New stored procedures and system wide views are normally implemented in the Resource database and installed as part of the setup.
If you have scripts where you specify the initial size of the database [especially SQL Express], make sure to consider this factor when migrating applications to SQL Server 2012.
Here is the query I used to find out what system tables were added in each version of SQL Server:
select object_name(p.object_id) as object_name , p.index_id , p.rows , au.total_pages
from sys.allocation_units au left outer join sys.partitions p on (au.container_id = p.hobt_id)
where au.type in ( 1 , 3 )
union
from sys.allocation_units au left outer join sys.partitions p on (au.container_id = p.partition_id)
where au.type in ( 2 )
The output I got from different versions is shown below with the changes highlighted. As you can see these system tables correspond to the new features introduced in SQL Server 2012 [e.g. AlwaysOn, Contained database, FileTable].
SQL 2012
SQL 2008 R2
object_name
index_id
rows
total_pages
size_bytes
filestream_tombstone_2073058421
1
0
2
filetable_updates_2105058535
queue_messages_1977058079
queue_messages_2009058193
queue_messages_2041058307
sysallocunits
138
4
32,768
103
16,384
sysasymkeys
3
sysaudacts
sysbinobjs
23
sysbinsubobjs
sysbrickfiles
syscerts
syschildinsts
sysclones
sysclsobjs
16
syscolpars
694
17
139,264
483
131,072
7
57,344
5
40,960
syscommittab
syscompfragments
sysconvgroup
syscscolsegments
syscsdictionaries
sysdbfiles
sysdbfrag
sysdbreg
sysdercv
sysdesend
sysendpts
sysfgfrag
sysfiles1
sysfoqueues
sysfos
sysftinds
sysftproperties
sysftsemanticsdb
sysftstops
sysguidrefs
sysidxstats
180
123
sysiscols
367
275
syslnklgns
sysmultiobjrefs
107
106
sysnsobjs
sysobjkeycrypts
sysobjvalues
187
125
24,576
25
204,800
sysowners
14
sysphfg
syspriorities
sysprivs
137
130
syspru
sysprufiles
sysqnames
98
97
sysremsvcbinds
sysrmtlgns
sysrowsetrefs
sysrowsets
124
91
sysrscols
870
632
9
73,728
sysrts
sysscalartypes
34
sysschobjs
2063
33
270,336
53
6
49,152
sysseobjvalues
syssingleobjrefs
155
146
syssoftobjrefs
syssqlguides
systypedsubobjs
sysusermsgs
syswebmethods
sysxlgns
sysxmitbody
sysxmitqueue
sysxmlcomponent
100
99
sysxmlfacet
112
sysxmlplacement
19
18
sysxprops
sysxsrvs
SUM
2,146,304
SQL 2008
SQL 2005
89
419
syshobtcolumns
538
syshobts
78
117
102
269
216
119
120
sysrowsetcolumns
27
47
sysserefs
133
93
1,228,800
1,163,264
NOTE: Do not query information directly from system tables or manipulate them. Use the documented and supported interfaces to query and modify the state of various SQL Server entities.
All the information provided above is based on SQL Server 2012 CTP3. It is possible there are changes when the product is released for production.
Thanks
Suresh Kandoth
SQL Server Escalation Services
Microsoft