How to set a database state to OFFLINE in MS SQL Server?
Submitted by: AdministratorIf you want to move database physical files, you should take the database offline by using the "ALTER DATABASE" statement with the following syntax:
ALTER DATABASE database_name SET OFFLINE
The following tutorial example will bring "GlobalGuideLine" offline:
ALTER DATABASE GlobalGuideLine SET OFFLINE
GO
SELECT name, state_desc from sys.databases
GO
name state_desc
master ONLINE
tempdb ONLINE
model ONLINE
msdb ONLINE
GlobalGuideLine OFFLINE
USE GlobalGuideLine
GO
Msg 942, Level 14, State 4, Line 1
Database 'GlobalGuideLine' cannot be opened because
it is offline.
Submitted by: Administrator
ALTER DATABASE database_name SET OFFLINE
The following tutorial example will bring "GlobalGuideLine" offline:
ALTER DATABASE GlobalGuideLine SET OFFLINE
GO
SELECT name, state_desc from sys.databases
GO
name state_desc
master ONLINE
tempdb ONLINE
model ONLINE
msdb ONLINE
GlobalGuideLine OFFLINE
USE GlobalGuideLine
GO
Msg 942, Level 14, State 4, Line 1
Database 'GlobalGuideLine' cannot be opened because
it is offline.
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Convert Binary Strings into Integers in MS SQL Server? |
☺ | What Happens If NULL Values Are Involved in Bitwise Operations? |
☺ | What Happens If You Insert a Duplicate Key for the Primary Key Column in MS SQL Server? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
☺ | How To Use Subqueries with the IN Operators in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Sybase Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |