sql-serverssmsssms-17

Executing multiple queries in SSMS


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.


Solution

  • 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