Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending multiple inserts to sql

Status
Not open for further replies.

stucker79

Technical User
Dec 7, 2004
25
US
I have queried Active Directory for a list of groups a particular user belongs to (comes back in an array). First, I need to loop through the array looking to see if any of 6 particular groups exist. Then, if any of them do exist, i need to update a table with this information. I am basically populating a table with userid and groupid combinations. Should I put this code in a for loop and send each individual insert to the database within the loop? i'm sure that's not the best way, any ideas here?
 
You can put them all into one SQL statement, separating them with a semicolon. But you should be aware that if any one of the insert statements fail, the remaining inserts won't be executed (and it's tough to figure out which one failed).

You can use a transaction, in which case if one of them fails, they all fail.

Also - what kind of volume are you talking about? Less than 50 rows, I wouldn't worry about it -- just use the loop.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
at most it would be 6. thanks for reminding me about how they could fail. i'll use a transaction, thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top