Sometimes you need to script out all the indexes in a database.
Maybe you’re concerned something has changed since they were last checked in.
Or maybe the indexes aren’t checked into source control, and you’re working on fixing that. (Important!)
Either way, sometimes you need to do it, and it’s not fun through the GUI. I needed to write some fresh demo code for this recently, and I needed it to give the details for partitioned tables using data compression, and I thought I’d share.
The fact that the built-in Generate Scripts does not include compression is annoying, but Kendra’s script does. For bonus points, use Powershell to update scripts automatically with index changes and check them into your source control system of choice.