views:

26

answers:

3

Hello,

What should I do to avoid that commands be executed each time I hit 'Execute !. icon'

I mean this

USE master;
GO
CREATE DATABASE Sales
GO
USE Sales;
GO
CREATE TABLE Customers(
CustomerID int NOT NULL,
LName varchar (50) NOT NULL,
FName varchar (50) NULL,
Status varchar (10),
ModifiedBy varchar (30) NULL        
    )
GO

When I click Execute!, Sql Server tries to redo the same thing.

What I do for now is to delete the Query Window completely then write what I need before clicking the Execute icon. But, I doubt that I should be doing that.

What can I do to keep writing the commands without having each time to clear the Query Window?

Thanks for helping

+2  A: 

You can highlight the command you wish to run prior to hitting execute and it will only run the selected query text, alternatively you can comment a single line out with a double dash sign e.g. -- , or comment a block of text out with /* */

Andrew
I see. So, there is no other way of preventing the query window to execute again commands that are present. Thanks to all
Richard77
@Richard 77, there are ways - read the other answers.
Raj More
You can select text you want commented out (usually whole lines) and press `Ctrl-K Ctrl-C` to comment that out. `Ctrl-K Ctrl-U` to uncomment.
Pasi Savolainen
+1  A: 

As far as I know there are only two option:

  • ctr + a en then delete
  • open a new query window
Ivo
A: 

New Query Window

Use Control+N to create a new window, write your query in there.

SELECT what you want

Click the Right Mouse button and drag to select what you want to execute, then execute the query

Raj More