MSSQL%20Interview%20Questions%20and%20Answers
Question: How to set a database state to OFFLINE in MS SQL Server?Answer: If 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 "withoutbook" offline: ALTER DATABASE withoutbook SET OFFLINE GO SELECT name, state_desc from sys.databases GO name state_desc master ONLINE tempdb ONLINE model ONLINE msdb ONLINE withoutbook OFFLINE USE withoutbook GO Msg 942, Level 14, State 4, Line 1 Database 'withoutbook' cannot be opened because it is offline. |
Is it helpful?
Yes
No
Most helpful rated by users:
- What is Microsoft SQL Server?
- What is the simplest way to create a new database in MS SQL Server?
- How to delete a database in MS SQL Server?
- How to download and install Microsoft .NET Framework Version 2.0?
- How To Get a List of Columns using the "sp_help" Stored Procedure in MS SQL Server?