Executing Marked Text in SQL Server Management Studio

In SQL Server Management Studio, you can use the Alt key in your keyboard to select blocks of text to execute. For instance, sometimes I create a SQL script to delete all the data in a specific database while I am testing the application. I don’t want to accidentally run the file and delete all the data when I shouldn’t, so I comment out all the delete statements. To execute them when I need to, instead of uncommenting them, I place the cursor right between the “–” and the “DELETE” keyword, press and hold the Alt key, left click and select all the statements I need, and then execute them.

For instance, suppose you have the following statements:

[email protected] FROM ORDERDETAIL--DELETE FROM ORDER--DELETE FROM PRODUCT--DELETE FROM PRODUCTCATEGORY--DELETE FROM CUSTOMER       #

You would place the cursor where the “@” symbol is, press and hold the Alt key, left click with the mouse and drag the cursor all the way to where the “#” symbol is. The “@” and “#” symbol are included here to show you the exact places, they shouldn’t be included in your statement. Also keep in mind that this selection method creates a rectangle so you have to select everything to cover the longest statement.

Notice how you have to drag the cursor all the way to the “#” symbol even when the last word was “CUSTOMER.” This is because a rectangle is formed and you need to cover the fourth line, which is the longest one.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

homes in the real estate industry

Exploring the Latest Tech Trends Impacting the Real Estate Industry

The real estate industry is changing thanks to the newest technological advancements. These new developments — from blockchain and AI to virtual reality and 3D printing — are poised to change how we buy and sell homes. Real estate brokers, buyers, sellers, wholesale real estate professionals, fix and flippers, and beyond may

man on floor with data

DevX Quick Guide to Data Ingestion

One of the biggest trends of the 21st century is the massive surge in internet usage. With major innovations such as smart technology, social media, and online shopping sites, the internet has become an essential part of everyday life for a large portion of the population. Due to this internet

payment via phone

7 Ways Technology Has Changed Traditional Payments

In today’s digital world, technology has changed how we make payments. From contactless cards to mobile wallets, it’s now easier to pay for goods and services without carrying cash or using a checkbook. This article will look at seven of the most significant ways technology has transformed traditional payment methods.