Candy
Candy

Reputation: 51

How to run more than one query at a time in SQL Server

I have to generate a big report consists of 45 insert statements. How can I Run more than one insert statement at a time it by splitting the queries into groups.

Upvotes: 1

Views: 1651

Answers (4)

alzaimar
alzaimar

Reputation: 4622

You might succeed in running multiple sessions (i.e. logins).[EDIT] I wrote, that an insert locks the table, which is wrong. Thanks @marc_s. [/EDIT]

However, if your insert precedes a complex query, you might be successful, as the queries could be carried out in parallel.

But, it greatly depends on the code.

Isn't there anything you can improve using the existing code? Usually, there is enough room for a performance boost just by looking at the statements.

Upvotes: 0

John Emeres
John Emeres

Reputation: 473

Try using multiple stored procedures where each stored procedure handles several insert statement. Even if you execute these procedures one by one they should be executed in parallel on SQL server as long as you’re using different connections.

Upvotes: 0

Harsh Vardhan Sharma
Harsh Vardhan Sharma

Reputation: 21

USe Stored Procedure for that and by using it u can return value also.

Upvotes: 1

Andy Cheng
Andy Cheng

Reputation: 1167

You can write 45 insert statements in stored procedure.

Upvotes: 0

Related Questions