Tweeted twitter.com/StackDBAs/status/945901097608253440
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
4 edited tags
| link
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
3 added 8 characters in body; edited title
source | link

What's the best practice of inserting a collection of data into sql servera SQL Server database

I am using c#C#, entity frameworkEntity Framework. sql serverSQL Server for the development. I have a method which has two parameters (int ID, List _listobjint ID, List<String> _listobj). For each ID, there is a list of obj. All of these IDs and lists will be inserted into different tables in database. So the question is: what's the best practice for this? I have couple of options:

  1. in c#, split the list as single value, then create a stored proc which takes two parameters (ID, str), then the c# will call the stored proc many times depending on the size of the list.

    In C#, split the list<obj> as single value, then create a stored procedure which takes two parameters (ID, str), then the C# will call the stored procedure many times depending on the size of the list

  2. passPass the IDID and listlist<obj> as two parameters to the stored procprocedure and let let the stored proc to spitprocedure split the listlist<obj>. This way the c#C# will only call call the stored procprocedure once.

    Is the second strategy doable? if yes, which is better in terms of performance?

Is the second strategy doable? If yes, which is better in terms of performance?

What's the best practice of inserting a collection of data into sql server database

I am using c#, entity framework. sql server for the development. I have a method which has two parameters (int ID, List _listobj). For each ID, there is a list of obj. All of these IDs and lists will be inserted into different tables in database. So the question is: what's the best practice for this? I have couple of options:

  1. in c#, split the list as single value, then create a stored proc which takes two parameters (ID, str), then the c# will call the stored proc many times depending on the size of the list.
  2. pass the ID and list as two parameters to the stored proc and let the stored proc to spit the list. This way the c# will only call the stored proc once.

    Is the second strategy doable? if yes, which is better in terms of performance?

What's the best practice of inserting a collection of data into a SQL Server database

I am using C#, Entity Framework. SQL Server for the development. I have a method which has two parameters (int ID, List<String> _listobj). For each ID, there is a list of obj. All of these IDs and lists will be inserted into different tables in database. So the question is: what's the best practice for this? I have couple of options:

  1. In C#, split the list<obj> as single value, then create a stored procedure which takes two parameters (ID, str), then the C# will call the stored procedure many times depending on the size of the list

  2. Pass the ID and list<obj> as two parameters to the stored procedure and let the stored procedure split the list<obj>. This way C# will only call the stored procedure once

Is the second strategy doable? If yes, which is better in terms of performance?

2 format
source | link

I am using c#, entity framework. sql server for the development. I have a method which has two parameters (int ID, List _listobj). For each ID, there is a list of obj. All of these IDs and lists will be inserted into different tables in database. So the question is: what's the best practice for this? I have couple of options: 1) in c#, split the list as single value, then create a stored proc which takes two parameters (ID, str), then the c# will call the stored proc many times depending on the size of the list. 2) pass the ID and list as two parameters to the stored proc and let the stored proc to spit the list. This way the c# will only call the stored proc once. Is the second strategy doable? if yes, which is better in terms of performance? thanks!

  1. in c#, split the list as single value, then create a stored proc which takes two parameters (ID, str), then the c# will call the stored proc many times depending on the size of the list.
  2. pass the ID and list as two parameters to the stored proc and let the stored proc to spit the list. This way the c# will only call the stored proc once.

    Is the second strategy doable? if yes, which is better in terms of performance?

I am using c#, entity framework. sql server for the development. I have a method which has two parameters (int ID, List _listobj). For each ID, there is a list of obj. All of these IDs and lists will be inserted into different tables in database. So the question is: what's the best practice for this? I have couple of options: 1) in c#, split the list as single value, then create a stored proc which takes two parameters (ID, str), then the c# will call the stored proc many times depending on the size of the list. 2) pass the ID and list as two parameters to the stored proc and let the stored proc to spit the list. This way the c# will only call the stored proc once. Is the second strategy doable? if yes, which is better in terms of performance? thanks!

I am using c#, entity framework. sql server for the development. I have a method which has two parameters (int ID, List _listobj). For each ID, there is a list of obj. All of these IDs and lists will be inserted into different tables in database. So the question is: what's the best practice for this? I have couple of options:

  1. in c#, split the list as single value, then create a stored proc which takes two parameters (ID, str), then the c# will call the stored proc many times depending on the size of the list.
  2. pass the ID and list as two parameters to the stored proc and let the stored proc to spit the list. This way the c# will only call the stored proc once.

    Is the second strategy doable? if yes, which is better in terms of performance?

1
source | link