A database scripts folder is a set of scripts that represent a database schema and, optionally, the data contained within. Scripts folders can be used to compare and deploy SQL Server database schemas, as well as version-control and reverse-engineer your databases. All of these operations can be done in a specialized tool called dbForge Schema Compare for SQL Server.
In this article, you will find a handy step-by-step tutorial that will show you how to create a scripts folder, save it on Microsoft OneDrive, and use it for the abovementioned purposes of schema comparison and deployment.
The use of OneDrive makes it very easy to do the following:
- Share scripts to conduct reviews
- Share scripts with your teammates for collaborative development
- Keep a copy of your database as a backup
How to set up OneDrive on your PC
Since you would like to use OneDrive for storage, we assume you already have an existing account; and now we would like to show you how to map it as a network drive on your Windows 10 machine and easily access your files and folders from File Explorer.
1. The OneDrive app comes preinstalled on Windows 10. Open it from the Start menu.
2. Enter the email address associated with your OneDrive account. Then click Sign in.
3. Enter your password and click Sign in again.
Take note that OneDrive may require additional verification and send a special security code to your associated email. If that happens, go to your email, get the security code, enter it, and move on.
4. Specify a location for your OneDrive folder.
5. If you set up OneDrive on your machine previously, you might already have an existing OneDrive folder. In that case, you can simply click Use this folder.
6. You will have to go through several additional pages that can be skipped; once it’s done, all of your OneDrive files and folders will appear in File Explorer.
That’s it! Now we can proceed to create a scripts folder in dbForge Schema Compare.
How to create a scripts folder and store it on OneDrive
You have two ways to create a new scripts folder in Schema Compare.
The first one is to go to the Database menu > Tasks > Create Scripts Folder or Snapshot.
1. In the Create Scripts Folder or Snapshot dialog that opens, specify the type of the source object, the required connection, database name, output type (Scripts Folder), and the path to OneDrive for your scripts folder to be saved to.
2. Optionally, you can also go to Scripts Folder Structure and specify the structure for your scripts folder and file name templates.
3. After everything is configured, click Create, and all database objects will be created and stored in your new scripts folder on OneDrive.
The second way is to create a scripts folder through the synchronization of your SQL Server database with an empty folder.
1. To do that, click New Schema Comparison on the menu to open the wizard.
2. In Source, select the Database type, then select the required connection and database. In Target, select the Scripts Folder type and set a path to an empty folder on your OneDrive in the Database scripts folder field.
3. Now click Compare. Once the comparison is completed, you will be able to specify the objects that will be added to the scripts folder (or simply keep all of them selected).
4. Open the synchronization wizard via the Comparison menu > Synchronize (or, alternatively, by selecting the required objects in the grid and selecting Synchronize from the shortcut menu).
Finally, select Update the scripts folder and click Synchronize. That’s it!
Using a scripts folder as a source or a target for comparison and synchronization
Whenever you use a scripts folder as a target or a source, Schema Compare generates an SQL synchronization script, which can be either saved to a file or viewed and modified in an internal editor.
If you select a scripts folder as a source, you can run the synchronization script directly against the required target database.
If you select a scripts folder as a target, your scripts folder will be updated.
Take note that you can also use scripts folders stored on OneDrive to version-control your SQL Server databases through dbForge Source Control, an add-in for SSMS that simplifies and automates database change management.
Download dbForge Schema Compare for a free 30-day trial
dbForge Schema Compare is available both separately and as part of Compare Bundle together with dbForge Data Compare—another valuable comparison tool, which helps locate, view, and sync differences in SQL Server table data. That said, we gladly invite you to download Compare Bundle for a free 30-day trial and see both of these tools in action.