IT tutorials
 
Database
 

SQL Server 2012 : Configuration Options (part 12) - Database-State-Configuration Properties

1/12/2014 2:17:56 AM
- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

12. Database-State-Configuration Properties

The database-state-configuration properties, as shown in Table 12, are available in SQL Server. These configurations are mostly used when a DBA performs maintenance on the database.

Table 12 Database-State-Configuration Properties

c19tnt012

You can set the state of the database with the ALTER DATABASE command. The sp_dboption command has been removed in this version of SQL Server and can no longer be used.

Database-Access Level

The database-access-configuration options set the state of the database. When the database is offline, no access to the database is enabled.

To set the AdventureWorks2012 sample database to an OFFLINE state in code, do the following:

ALTER DATABASE AdventureWorks2012 SET OFFLINE;

To revert this change and make the AdventureWorks2012 database online and available in code, execute the following command:

ALTER DATABASE AdventureWorks2012 SET ONLINE;

You may encounter a situation in which the database is inaccessible and you do not have a backup. To access the database no matter what state things are, members of the sysadmin role can put the database in EMERGENCY mode. When in EMERGENCY mode, the database is in read-only mode and is accessible only by members of the sysadmin role. To put the AdventureWorks2012 sample database in EMERGENCY mode in code, execute the following command:

ALTER DATABASE AdventureWorks2012 SET EMERGENCY;

The READ_ONLY database-state settings enable only selects from the database. READ_ONLY cannot take effect if any users are in the database. To reset the database to a normal read-and-write state, the READ_WRITE database setting is used.

To set the AdventureWorks2012 sample database to a READ_ONLY state in code, do the following:

ALTER DATABASE AdventureWorks2012 SET READ_ONLY;

The restricted access database-state settings are also available. The three restricted access levels are single_user, restricted_user, and multi_user states. These settings control which users are allowed to access the database. The SINGLE_USER setting is appropriate when you do database maintenance. The RESTRICTED_USER setting enables database access only to users in the db_owner, dbcreator, and sysadmin roles. The MULTI_USER setting is used to set the database in the normal operating state.

To set the AdventureWorks2012 sample database to SINGLE_USER access in code, do the following:

ALTER DATABASE AdventureWorks2012 SET SINGLE_USER;

To revert this change and set the AdventureWorks2012 database access to MULTI_USER access in code, do the following:

ALTER DATABASE AdventureWorks2012 SET MULTI_USER;

Compatibility Level

In SQL Server, the database-compatibility level can be set to 90 (SQL Server 2005), 100 (SQL Server 2011) or 110 (SQL Server 2011). When a database is upgraded to SQL Server 2012 from any earlier version of SQL Server, the database retains its existing compatibility level. If the original compatibility level of the database is 80 (SQL Server 2000) or earlier, then the database automatically is set to the server's lowest compatibility mode, which is 90 (SQL Server 2005). Setting the database-compatibility level to a level lower than 110 may be necessary if you upgrade the Database Engine and still need to maintain the behavior of an earlier version of SQL Server.


To set the compatibility level of the AdventureWorks2012 sample database to 110 (SQL Server 2012) in code, do the following:

ALTER DATABASE AdventureWorks2012 SET COMPATIBILITY_LEVEL = 110;

Tip
To view the compatibility level of SQL Server, query the compatibility_level column in the sys.databases catalog view.
 
Others
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
Technology FAQ
- Is possible to just to use a wireless router to extend wireless access to wireless access points?
- Ruby - Insert Struct to MySql
- how to find my Symantec pcAnywhere serial number
- About direct X / Open GL issue
- How to determine eclipse version?
- What SAN cert Exchange 2010 for UM, OA?
- How do I populate a SQL Express table from Excel file?
- code for express check out with Paypal.
- Problem with Templated User Control
- ShellExecute SW_HIDE
programming4us programming4us