Scripting Objects

The most common argument I hear against EM is that creating objects through a GUI as opposed to script-based management means you don't have a saved script to re-create the object if required. Fortunately, EM allows you to create and save a script to create a single object such as a view or all objects within a particular database. To create a script, select the object, right-click, and from the All Tasks menu, select Generate SQL Script. This will open the Generate SQL Scripts dialog box, as shown in Figure 4.29.

Figure 4.29. The Generate SQL Scripts dialog box.


The Preview button allows you to see the format of the script, as seen in Figure 4.30.

Figure 4.30. Previewing the script.


To set up the format of the script, use the Formatting tab to set whether drop commands should be included. This is illustrated in Figure 4.31.

Figure 4.31. The Formatting tab of the Create Script dialog box.


Additional options can be set on the Options tab. One complaint I often hear is that the objects are scripted but not the actual database. This is available under Options, but is not selected by default. As a matter of fact, if you don't select user objects and check the Script Database box, you will generate a script that just creates the database structure. Figure 4.32 shows the Options tab.

Figure 4.32. The Options tab of the Create Script dialog box.


Microsoft SQL Server 2000 Unleashed
Microsoft SQL Server 2000 Unleashed (2nd Edition)
ISBN: 0672324679
EAN: 2147483647
Year: 2002
Pages: 503

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: