|
How do I in bulk INSERT or UPDATE an array of values, without using simple iteration? Something like:
(comments are locked)
|
|
NOTE: Edited to fix issue with copying and pasting the stored procedure code. My inline tabs were being converted to spaces, so I replaced them with CHAR(9). Also, see note at bottom for a potential real-world example. This one took me a little while, but I just knew I could figure it out if I kept trying. I wrote it as a stored procedure for easy reuse.
Sample usage:
Table Contents:
This is just a simple example. A real-world example might be something like this: @BigArray = a list of part numbers to add to inventory
(comments are locked)
|
|
I ran your code, but it produced NULL values for @SqlStmt.
My question is: If you know in advance that those four elements (1,3,13,31) are the only ones that matter, why not just insert them? Simple and easy to read and understand
Oct 19 '09 at 11:50 PM
Jack Corbett
Thanks, Jack. I think it would win on performance too.
Oct 22 '09 at 10:35 AM
Bob Hovious
(comments are locked)
|


Can you clarify on what you mean a bit? I don't think the question is really answerable in it's current form...
Please also add some code and sample data to show how you are phrasing the question.
I don't really have any sample in front of me, this is something that has come up in the past. I'll come up with something to help clarify. I just want to insert an array of data with one (or a few commands) instead of looping through every element inserting each one individually.