Search code examples
sql-servergitignore

How prevent the script date line from makig GIT flag every file as changed with SQL Server scripted objects


I'm using GIT to archive my SQL Server database design by using the Tasks --> Generate Scripts option from SQL Server Management Studio context menu of the database object.

Using this to generate scripts file for each object in the database results in a comment line being added at the top of each file with a timestamp showing when the script was generated.

/****** Object:  Trigger [MyTrigger]    Script Date: 07/07/2015 11:58:15 ******/

When I export the whole database to my Git folder to see what's changed, this line makes GIT think that every single file has changed, but I'm not interested in that change. My current work-around is to do a bulk find/replace in Notepad++ and and convert all the timestamp numbers to zero.

The regex search string is:

Script Date\: \d+\/\d+\/\d+ \d+\:\d+\:\d+

I then replace all the numbers with zeros:

Script Date: 00/00/0000 00:00:00

However... this seems like an unnecessary step. Is there a better way?


Solution

  • You can turn off this option completely:

    enter image description here

    Click on the Advanced button, and then set the Include descriptive headers option to false:

    enter image description here