Try using an array. For example:
excludes=(file1.txt file2.txt '*.sql')
rsync -azhi --dry-run $(printf -- "--exclude=%s " "${excludes[@]}") /from-directory/ /to-directory/
BTW, don't enclose `*.sql` in single-quotes if you **want** it to expand to all .sql files in the current dir. I'm guessing that's NOT what you want it to do, so I've quoted it.
That will expand to:
rsync -azhi --dry-run --exclude=file1.txt --exclude=file2.txt --exclude=*.sql /from-directory/ /to-directory/
alternatively:
rsync -azhi --dry-run --exclude="$(printf -- "%s," "${excludes[@]}" |
sed -e s/,$//)" /from-directory/ /to-directory/
will expand to:
rsync -azhi --dry-run --exclude=file1.txt,file2.txt,*.sql /from-directory/ /to-directory/