locked
how to run multiple procedure in different tabs at one time in sql server RRS feed

  • Question

  • User-1634604574 posted

    i am opened multiple procedures each of them in a different tab i mean i opened 10 procedures in 10 tabs how can i execute all of them at one time by one click?

    is there any way to do that?

    Monday, July 13, 2020 11:41 AM

All replies

  • User475983607 posted

    i am opened multiple procedures each of them in a different tab i mean i opened 10 procedures in 10 tabs how can i execute all of them at one time by one click?

    is there any way to do that?

    Your question makes little to no sense.  If you are ask about how to use SQL management studio then you have to open each tab and run the code one at at time.  If you want all the code to run copy the code to a single file.  If the code is actually stored procedure then just create a file that calls each procedure.

    Monday, July 13, 2020 11:47 AM
  • User753101303 posted

    Hi,

    You mean using SSMS? You could perhaps https://docs.microsoft.com/en-us/sql/t-sql/language-elements/waitfor-transact-sql?view=sql-server-ver15 to delay execution until a given date/time.

    You are trying to test something in particular? It could be easier to help knowing what exactly you are trying to do.

    Edit: not just that you are trying to run 10 procedures at the same time but which kind of benefit you expect from doing that

    Monday, July 13, 2020 11:50 AM
  • User-1634604574 posted

    i have 10 procedures opened in 10 tabs it mean each of them opened in separate tab i want to execute all tabs by one click

    Monday, July 13, 2020 12:17 PM
  • User475983607 posted

    i have 10 procedures opened in 10 tabs it mean each of them opened in separate tab i want to execute all tabs by one click

    SSMS does not have this feature.  For the second time, either create one file that contains all the SQL that you wish to submit to the SQL server or if the code is actual procedures then just call each procedure using basic TSQL code.   

    You could have solved this very simple programming problem in the time it has taken you to post on the forum.  

    Monday, July 13, 2020 12:32 PM
  • User-1634604574 posted

    can you write the code?

    Monday, July 13, 2020 12:53 PM
  • User77042963 posted

    Do you have a list of your stored procedure names?

    Monday, July 13, 2020 1:43 PM
  • User-1634604574 posted

    no i just saved them as an sql file in a folder

    Monday, July 13, 2020 3:01 PM
  • User475983607 posted

    no i just saved them as an sql file in a folder

    Why can't you copy and paste the SQL into one file? 

    Monday, July 13, 2020 3:09 PM
  • User-1634604574 posted

    it take a long time i have 668 procedures 

    Monday, July 13, 2020 3:17 PM
  • User475983607 posted

    it take a long time i have 668 procedures 

    Really?  You started with 10 tabs.  Please do not waste everyone's time solving fake requirements. 

    Execute the SQL files from the command line.  You'll need to write the code.  

    https://docs.microsoft.com/en-us/sql/ssms/scripting/sqlcmd-run-transact-sql-script-files?view=sql-server-ver15

    Monday, July 13, 2020 3:21 PM
  • User-1634604574 posted

    my post is not fake i don't like this word please don't say again , i just posted as an example in real;y i will open 668 tab i want execute them at one time

    Monday, July 13, 2020 3:29 PM
  • User77042963 posted

    my post is not fake i don't like this word please don't say again , i just posted as an example in real;y i will open 668 tab i want execute them at one time

    exec mysp1;
    exec mysp2;
    exec mysp3;

    ....

    Monday, July 13, 2020 5:27 PM
  • User753101303 posted

    i have 10 procedures opened in 10 tabs it mean each of them opened in separate tab i want to execute all tabs by one click

    No. I meant that this is just  something that is supposed to solve a problem or give you some expected result. For now I'm trying to understand the non technical need that make you think you should open a tab for each SQL file and run them in parallel rather than one after the other ???

    Ah or you just want to run scripts one after the other (and in which order ?). For example if you tell us this is to create a db for your app you could :
    - backup/restore another db and clear data to get an empty db you'll be able to restore as well
    - or you could use https://docs.microsoft.com/en-us/sql/ssdt/how-to-create-a-new-database-project?view=sql-server-ver15  to manage your project database etc...
    - at worst you could write custom code to run files one after the other but it's liekly it needs to be done in a given order

    I wonder if all those scripts you have are not taken from a database project ? See also maybe https://stackoverflow.com/questions/22381755/sqlcmd-include-all-scripts-in-folder

    In short I'm trying to understand really WHAT you are trying to do. For now what you describe is rather HOW you plan to do something we don't known about.

    Wednesday, July 15, 2020 11:28 AM