Home > other >  Executing multiple queries in SSMS
Executing multiple queries in SSMS

Time:09-28

Is there a possibility to run many queries, that are not next to each other in the text editor in SSMS, at one time?

Assuming we have:

select * from tab1
select * from tab2
select * from tab3

the aim is to somehow mark only first and last selects and run them at the same time.

CodePudding user response:

In SQL Server management you can just select the query you want to execute and press F5

EDIT: YOu can even select a part of a query to execute only that part. Example: SELECT * FROM <table> WHERE <your where> And you select just after the <table> then your query will be executed without the WHERE

enter image description here

EDIT: ctrl alt your select enter image description here

CodePudding user response:

You can comment / uncomment a query easily by [un]commenting multiline comment start line. The second query is commented

select * from tab1;
/*
select * from tab2;
--*/
select * from tab3;

now it's uncommented

select * from tab1;
--/*
select * from tab2;
--*/
select * from tab3;
  • Related