Toad World® Forums

Script generation for SQL Server - how to add 'use <database>' at the beginning of the script

Hello:

I am working on database changes that involve the creation of new tables. Using the Actions mechanism in the DDL Script Generation dialog I generate scripts for the set of tables I added, and I usually set Check Constraint Rules to Drop & Create, Entities to Drop & Create and so on so I can re-run the script many times.

The problem that I have is that I also need to add:

use

go

at the beginning of the script to set the proper context for the script.

How can I do that, so I don’t have to add the two lines manually every time I generate the script?

I added the two lines in the Before Script for each table but the constraint & FKs drop statement happen earlier in the script.

Any suggestions?

Thank you

I solved it by adding the two lines to the Before Script field in the Model Properties dialog.