1

I've been a long time Oracle user and generally if I needed to run multiple SQL queries, I would end one with a semicolon (;) and then start the new one. Example:

Select * from dual;
Select * myTable;

Questions:

  1. How can I go about running the whole script in SQL Server?
  2. How can I replicate the behavior where if I put the cursor on the second SQL statement and press F9 (or F5 in SQL Server) that only the second statement runs? In other words, if I put my cursor anywhere in the current SQL statement and press the Execute button, it will run everything after the previous semicolon (;)?

Thank you.

2
  • You can run multiple queries in SQL Server by separating them with a colon. Try doing this in SQL Server Management Studio. Commented Nov 2, 2014 at 17:15
  • For question 2, you probably can't. Highlighting the sql block and pressing F5 might be as good as it gets. Commented Nov 2, 2014 at 17:31

1 Answer 1

4
  1. Sql Server is very permisive and you just need to write the statements in the text editor window and hit run to execut everything, you don't need anything explicit to separate them. That's if you use Management Studio. In Management Studio you can also separate batches using the GO keyword.

  2. If you want to run a specific statement in the text editor window you just need to highlight the statements you want to run and then hit run with them highlighted and Management Studio will execute only the selected statement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.