6.3.1 Browse the database with Enterprise Manager
SQL Server provides a way of browsing the directory tree, making it easy and quick to browse database information. Click the database folder you want to browse in Enterprise Manager to see the basic information (general), table and index information (tables & Indexes) of the database in the Task Pad window on the right, The configuration of the database file (space allocated) is shown in Figure 6-8. After you open the database folder tree, you can select various database objects for information browsing.
6.3.2 Display database information with system stored procedures
SQL Server Provides many useful system stored procedures that you can use to get a lot of information that is not easy or visible from the Enterprisemanager interface (see the "Stored Procedures" section for a detailed description of stored procedures.) It doesn't matter if the reader doesn't understand the stored procedure at the moment, it can be used as a function or a command.
(1) display the database structure with system stored procedures
You can use system-supplied system stored procedure sp_helpdb to display the database structure.
Its syntax is as follows:
sp_helpdb [[@dbname =] ' name '
uses sp_helpdb system stored procedures to display information about the specified database. If you do not specify a [@dbname =]
' name ' clause, all database information stored in the Master.dbo.sysdatabases table is displayed. command to
work will return 0, otherwise return 1.
Example 6-4: Displays information about the MyDB database that was created in the previous section.
Exec sp_helpdb mydb
(2) Displaying file information with system stored procedures
You can use system-supplied system stored procedure sp_helpfile to display file information in the current database. The syntax is as follows:
Sp_helpfile [[@filename =] ' name '] If you do not specify a file name, all file information in the current database is displayed. Successful execution of the command returns 0, otherwise it returns 1.
Example 6-5: Displays information about the Mydb_data1 file in the MyDB database.
Use mydb
exec sp_helpfile mydb_data1
(3) Display filegroup information with system stored procedures
You can use system-supplied system stored procedure sp_helpfilegroup to display filegroup information in the current database. The syntax is as follows:
Sp_helpfilegroup [[@filegroupname =] ' name '
If you do not specify a filegroup name, all filegroups in the current database are displayed. Successful execution of the command returns 0, otherwise it returns 1.
Example 6-6: Displays information about the DATA2 filegroup in the MyDB database.
Use mydb
exec sp_helpfilegroup data2