You can comment and uncomment portions of your text by using the Comment button on the toolbar. Text that is commented out is not executed.
Open SQL Server Management Studio.
Connect to your SQL server.
Open a New Query window.
Paste the following Transact-SQL code in your text window.
USE master
GO
-- Drop the database if it already exists
IF EXISTS (
SELECT name
FROM sys.databases
WHERE name = N'TutorialDB'
)
DROP DATABASE TutorialDB
GO
CREATE DATABASE TutorialDB
GO
ALTER DATABASE [TutorialDB] SET QUERY_STORE=ON
GO
5. Highlight the Alter Database portion of the text, and then select the Comment button on the toolbar:
6. Select Execute to run the uncommented portion of the text.
7. Highlight everything except for the Alter Database command, and then select the Comment button:
Note
The keyboard shortcut to comment text is CTRL + K, CTRL + C.
8. Highlight the Alter Database portion of the text, and then select the Uncomment button to uncomment it:
Note
The keyboard shortcut to uncomment text is CTRL + K, CTRL + U.
9. Select Execute to run the uncommented portion of the text.