Source controlling custom scripts

Applies to
ApexSQL Source Control

This article describes how to use the Custom scripts feature.

In some situations, like the development of commercial software, it is a requirement to version control not only the database itself but custom SQL scripts and even programming code e.g. C#. Using this feature, a user can include any text based scripts including SQL, client code e.g. C#, Java, that can be version controlled along with database changes.


To add custom scripts in version control, navigate to the Options form, from the add-in main menu:

In the Options form, switch to the Action center tab. In the Custom scripts section, select the appropriate server and a database that you want to add custom scripts for, and click the browse button to locate and assign the folder where custom scripts are stored:

Navigate to the folder in the file system where custom scripts are stored and click the OK button to confirm:

Click the OK button in the Options form, to complete the operation, and initiate/refresh the Action Center tab using the Action center command from the ApexSQL toolbar:

All scripts will be presented in the Action center tab, and from this point, they will be treated like SQL database objects. Once the scripts are initially committed to the repository, the user will be able to track all the changes. In addition, any version of the custom script committed to the repository can be found in the project history form.

Ways to set up the custom scripts folder

Using the “centralized” custom scripts folder

Regardless of the development model, custom scripts folder can be set on a network location that all team members have access to. In this way, the custom scripts folder acts as a “central repository” for the custom scripts, and all users who set the corresponding path of the custom scripts folder to point to the network location where the folder is stored, will be able to track all the changes made by the rest of the team.

Using an empty local folder to pull the custom scripts from the repository

In a situation where the custom scripts folder cannot be placed on a network location and used as described in the previous paragraph, one of the users can set the local folder where the custom scripts are stored and initially commit all of them to the repository.

The rest of the team will need an empty folder on local machines set as a custom scripts folder. After the custom scripts folder is set, each user can simply pull them from the remote repository to the corresponding local folder.

Using a local folder for independent work

Even if the team is working on the same database using the shared model, the custom scripts folder does not have to be centralized. Depending on the nature of the work and the need for using the custom scripts, not all team members may need to use/share the same custom scripts.

Quick tip icon

Quick tip:

For a single database only one folder/path can be set as a custom scripts folder meaning that you cannot use the shared custom scripts folder and have another folder on a local machine set as a custom scripts folder.

Filtering custom scripts

In some cases, when the team is working with multiple custom scripts, each user may need to track only specific scripts or a group of scripts. By filtering on each local machine, users can have only the selected (filtered) scripts showing (being tracked) in the Action center tab.

To filter custom scripts before pulling any of them from source control, navigate to the add-in options and switch to the Object filtering tab. Click the Show objects button, to initiate two tabs to appear at the bottom of the form. Select the Repository only tab, and check custom scripts that you want to track:

Q: What kind of custom scripts are supported?

A: Any kind of script regardless of the programming language. Basically, any text based file

Q: What are the necessary pre-requisites for adding custom scripts?

A: The only pre-requisite, is having a linked database

Q: Does anything needs to be initially committed in order to add custom scripts?

A: No, commits are not necessary in order to add custom scripts.

Q: Is there a way that custom scripts can be affected with database policies when working in the shared model?

A: No, database policies can be applied to database objects only, and do not have any effect on custom scripts.

Q: Will the actual change made in the custom script will be visible in the Database change log form, when working in the shared model?

A: No, the Database change log feature has the same scope of appliance as database policies. It affects only database objects and cannot be applied to custom scripts.

Q: If a conflict occurs with the custom scripts in the dedicated development model, will ApexSQL Source Control be able to resolve it in the same way as it works for database objects?

A: Yes, all options available for resolving conflicts when working with database objects are available when resolving conflict of a custom scripts.

Q: Does each user need to have some custom script in the custom scripts folder in order to see other’s committed custom scripts?

A: No, if a single user just wants to keep up the track of already committed custom scripts, an empty folder on a local machine needs to be set as a custom scripts folder. Upon refreshing the action center, the user can apply/pull all the scripts from the repository and store them locally