I am trying to write a batch script to run a bunch of T-SQL scripts I keep in version control. The scripts update objects in the database. The script seems to be working fine. The problem is that when I then script the objects back out to the files, there is an extra newline before the end of the script. This causes all of my scripts to show that they were changed when all that has changed is a single newline. If I were to continue this procedure for a while, I would end up with a lot of blank space at the end of each script. I am using the following command to run each script:
sqlcmd -S "(local)" -d "MyDatabase" -E -I -i "MyScript.sql"