Skip to content
Advertisement

SQL: How to write multiple interactive scripts in one query (insert rows)

Simple question- I just want to learn how to write a query that will insert 2 rows into my table by writing one query, instead of 2 separate ones. My queries work completely fine, I just want to know a simpler way, if that’s possible. Below are my 2 queries that I’d like to combine into 1.

As I stated above, my code works as expected. Here is my output with NO errors-

Thank you for anyone’s help!

Advertisement

Answer

Its not totally clear what you’re asking for, but you can make your inserts 1 script execution with:

However it looks like you may want to use a cursor to loop through the list of values and insert them somewhere else.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement