You may read the Microsft Article Reindex the WSUS Database. This article does not document that the command has changed under Windows 2012. If you are using Windows Internal Database (WID) for the WSUS database, you need to use the sqlcmd utility.
To use this script with Windows Internal Database, you should run the following command:
sqlcmd -E -S np:\\.\pipe\MICROSOFT##WID\tsql\query -i WsusDBMaintenance.sql
or with logging to a file:
sqlcmd -E -S np:\\.\pipe\MICROSOFT##WID\tsql\query -i WsusDBMaintenance.sql > WsusDBMaintenance.log 2>&1