Enterprise Manager provides a visual interface in which the database and its objects, such as tables, views, defaults, and so on, rarely require the user to edit their own program code. But it is good for users to understand how these objects are built through the SQL language and get their SQL language scripts (script). provides tools in enterprise Manager to help users generate SQL language scripts for these objects.
The SQL script method that generates the object is as follows:
(1) Select the object in Enterprise Manager to generate the SQL script, right-click, and choose Generate SQL Scripts menu item from the All Tasks submenu on the shortcut menu, and the dialog box shown in Figure 5-15 appears.
(2) When you set an option in the SQL Script Generation dialog box, clicking the "Preview" button pops up the preview dialog shown in Figure 5-16. You can click the "Copy" button to copy the script statement to the Clipboard. You can also select the "OK" button in Figure 5-15 to specify the script filename and location.
The SQL script generated by Enterprise Manager is a file with a suffix named ". sql", which is actually a text file, which can be browsed or modified in Enterprise Manager or another file editor. If necessary, you can generate SQL scripts for all database objects as a backup of the database. When the database is corrupted, you can run this SQL script in query Analyzer to rebuild the database.
See the full set of "MS SQL Basics Tutorials"