Posts

What are the SQL Server system databases and can you outline the general functionality of each database?

What are the SQL Server system databases and can you outline the general functionality of each database? Master - Database responsible for SQL Server instance related data.  You can also think of this database corresponding to the Windows SQL Server service account. Resource - Database responsible for SQL Server system objects.  This database was introduced in SQL Server 2005 and is intended to ease the upgrade and rollback of SQL Server system objects. Model - Template database for the creation of new user defined databases. MSDB - Database responsible for SQL Server Agent related data such as Jobs, Alerts, Operators, etc. TempDB - Temporary database to store temporary tables (#temptable or ##temptale), table variables, cursors, work tables, row versioning, create or rebuild indexes sorted in TempDB, etc.  Each time the SQL Server instance is restarted all objects in this database are destroyed, so permanent objects cannot be created in this databa...

System Databases Do's and Don'ts

System Databases Do's and Don'ts Data Access - Based on the version of SQL Server query only the recommended objects.  In general the system database objects are being deprecated to a set of views, so be sure all of your scripts are accessing the right objects.  If not, you are going to have a big project in the future to convert all of your scripts. Changing Objects - Do not change system objects.  In SQL Server 2005 all of the database objects have been moved to the Resource database which stores the definition for the system objects and can be updated via new SQL Server releases independent of the data. New Objects - Creating objects in the system databases is not recommended.  If you have objects that are needed for the instance i.e. administrative items, just create a separate DBA database to store these objects. Sneaking a Peak - Up to this point, all of the T-SQL code for the tables, views, stored procedures, functions, etc. has been ...

SQL Server System Databases

SQL Server System Databases Master Database Purpose - Core system database to manage the SQL Server instance.  In SQL Server 2005, the Master database is the logical repository for the system objects residing in the sys schema.  In SQL Server 2000 and previous editions of SQL Server, the Master database physically stored all of the system objects. Prominent Functionality Per instance configurations Databases residing on the instance Files for each database Logins Linked\Remote servers Endpoints Additional Information The first database in the SQL Server startup process In SQL Server 2005, needs to reside in the same directory as the Resource database Sources for Database Information - SQL Server 2000 to 2005 Crosswalk SQL 2000 to 2005 Crosswalk - Startup Parameters Resource Database Purpose - The Resource database is responsible for physically storing all of the SQL Server 2005 system objects. This database has been created to impr...

SQL Text vs VARCHAR

When to use VARCHAR and When to use TEXT TEXT is used for large pieces of string data. If the length of the field exceeed a certain threshold, the text is stored out of row. VARCHAR is always stored in row and has a limit of 8000 characters. If you try to create a VARCHAR(x) , where x > 8000 , you get an error: Server: Msg 131, Level 15, State 3, Line 1 The size () given to the type ‘varchar’ exceeds the maximum allowed for any data type (8000) These length limitations do not concern VARCHAR(MAX) in SQL Server 2005 , which may be stored out of row, just like TEXT . Note that MAX is not a kind of constant here, VARCHAR and VARCHAR(MAX) are very different types, the latter being very close to TEXT . In prior versions of SQL Server you could not access the TEXT directly, you only could get a TEXTPTR and use it in READTEXT and WRITETEXT functions. In SQL Server 2005 you can directly access TEXT columns (though you still need an explicit cast...

SQL SERVER – ACID (Atomicity, Consistency, Isolation, Durability)

ACID (an acronymn for Atomicity Consistency Isolation Durability) is a concept that Database Professionals generally look for when evaluating databases and application architectures. For a reliable database all this four attributes should be achieved. Atomicity is an all-or-none proposition. Consistency guarantees that a transaction never leaves your database in a half-finished state. Isolation keeps transactions separated from each other until they’re finished. Durability guarantees that the database will keep track of pending changes in such a way that the server can recover from an abnormal termination. Above four rules are very important for any developers dealing with databases. Reference : Pinal Dave ( http://blog.SQLAuthority.com )

What is XML Datatype?

What is XML Datatype? The xml data type lets you store XML documents and fragments in a SQL Server database. An XML fragment is an XML instance that is missing a single top-level element. You can create columns and variables of the xml type and store XML instances in them. The xml data type and associated methods help integrate XML into the relational framework of SQL Server.

Which are new data types introduced in SQL SERVER 2008?

Which are new data types introduced in SQL SERVER 2008? The GEOMETRY Type: The GEOMETRY data type is a system .NET common language runtime (CLR) data type in SQL Server. This type represents data in a two-dimensional Euclidean coordinate system. The GEOGRAPHY Type: The GEOGRAPHY datatype’s functions are the same as with GEOMETRY. The difference between the two is that when you specify GEOGRAPHY, you are usually specifying points in terms of latitude and longitude. New Date and Time Datatypes: SQL Server 2008 introduces four new datatypes related to date and time: DATE, TIME, DATETIMEOFFSET, and DATETIME2. DATE : The new DATE type just stores the date itself. It is based on the Gregorian calendar and handles years from 1 to 9999. TIME : The new TIME ( n ) type stores time with a range of 00:00:00.0000000 through 23:59:59.9999999. The precision is allowed with this type. TIME supports seconds down to 100 nanoseconds. The n in TIME ( n ) defines this level of f...