install all sql files in doc and make sure the names don't collide

closes #1619 (commit of this pull is include in this one)
fixes #1501