Home > SQL > Processing multiple data in a single call SQL Query

Processing multiple data in a single call SQL Query

Say you want to insert multiple rows of data in single shot query, how you accomplished that ?

There are several ways. Two of them I’ve used, they are:

1. Via XML parameter.

Bundle multiple data values into XML then pass to a procedure or statement. In a procedure or statement, use Nodes method to process that data in a single call. Here’s one of the example I’ve found in the Net : http://www.thinkingcog.com/post/2014/02/15/Inserting-multiple-rows-in-SQL-Server-database.aspx

2. Via Table-Valued parameter.

Here you have to create table type first before we can use table-value parameter in procedure. Completed how-to and sample can be found in MSDN link here : https://msdn.microsoft.com/en-us/library/bb675163(v=vs.110).aspx . But remember it only available at SQL 2008 or higher.

Categories: SQL Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: