Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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"
share|improve this question
up vote 1 down vote accepted

I think the problem is with SQL Server's script generator, see this bug report for more info.

share|improve this answer
It says that was closed as fixed, but it doesn't say when. It looks like they planned to fix it in a service pack of SQL Server 2005 and I am running 2008. – Schmalls Aug 31 '12 at 21:31
Also, it says the newlines would show at the beginning of the file and mine are showing up at the end. However, I am relatively certain that the problem is with the script generator. – Schmalls Aug 31 '12 at 21:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.