The "magic" is a procedure that MS has graciously provided us that does all of the heavy-lifting:
This can certainly be improved upon. One simple thing to make it more robust would be to allow it to add new groups or validate groups being passed in. I'll let that as an exercise for the reader.
Dave Wentzel CONTENT
sql server