sql step by step

Upload: jackstone82

Post on 05-Apr-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 SQL Step by Step

    1/2

    Page 0

    SQLSERVER 2008-STEP-BY-STEP GUIDES

    CONTENTS

    Filegroups .................................................................................................................................................................0

    Add a Filegroup to a Database .............................................................................................................................0

    Check the status of the Filegroups .......................................................................................................................0

    Databases .................................................................................................................................................................0

    Create a new database .........................................................................................................................................1

    Create a new schema ...........................................................................................................................................1

    Add a schema .......................................................................................................................................................1

    Check the database table status ..........................................................................................................................1

    Policy Management..................................................................................................................................................1

    Define the New Custom Policy .............................................................................................................................1

    FILEGROUPS

    Add a Filegroup to a DatabaseClick Start, and then click SQL Server Management Studio.

    The Connect to Server dialog box appears. Click Connect.In the Object Explorer pane, expand Databases, and then click your database.

    Right-click your database, and then click Properties.

    The Database Properties dialog box appears. In the Select a page pane, click Filegroups.

    Click Add.

    In the Name field, type SecondaryFilegroup.

    Set the Filegroup to Read-only

    Select the Read-Only check box.

    Click OK.

    Check the status of the FilegroupsIn the Object Explorer pane, click your database.

    Right-click your database, and then click Properties.

    The Database Properties dialog box appears. In the Select a page pane, click Filegroups.

    Examine the current filegroups.

    Click Cancel.

    DATABASES

  • 7/31/2019 SQL Step by Step

    2/2

    Page 1

    Create a new databaseClick Start, and then click SQL Server Management Studio.

    The Connect to Server dialog box appears. Click Connect.

    In the Object Explorer pane, expand Databases, and then click AdventureWorks2008.

    Right-click AdventureWorks2008, and then click New Database.

    The New Database window opens. In the Database name field, type AdventureWorksDemo, and then click OK.

    Create a new schemaIn the Object Explorer pane, expand AdventureWorksDemo | Security | Schemas.

    Right-click Schemas, and then click New Schemas.

    In the New Schemas window, in the Schemas name field, type SchemaDemo, and then click OK.

    Add a schemaIn the Object Explorer pane, expand AdventureWorksDemo, and then click Tables.

    Right-click Tables, and then click New Table.

    In the Properties pane, in the name field, type DemoTable.

    In the Schema list, click SchemaDemo.In the Column Name field, type FirstColumn.

    On the toolbar, click Save DemoTable.

    Check the database table statusIn the Object Explorer pane, expand Tables, and then click db_owner.DemoTable.

    Right-click db_owner.DemoTable, and then click Properties.

    The Table Properties DemoTable window opens. Examine the properties of the DemoTable table.

    POLICY MANAGEMENT

    Define the New Custom PolicyClick Start, and then click SQL Server Management Studio.

    The Connect to Server dialog box appears. Click Connect.

    In the Object Explorer pane, navigate to NY-SQL-01 | Management | Policy Management | Facets | Table.

    Right-click Table and then click New Condition.

    The Create New Condition window opens. In the Name field, type Table Condition.

    In the Expression box, in the Field list, click @HasIndex.

    Make sure that the Operator list is set to =.

    In the Value list, click True.

    Click OK.

    In the Object Explorer pane, right-click Policies, and then click New Policy.

    The Create New Policy window opens. In the Name field, type Table Policy.

    In the Check condition list, click Table Condition.

    In the Against targets box, in the Every Database list, click New condition.

    The Create New Condition window opens. In the Name field, type AdventureWorks2008.

    In the Expression box, in the Field list, click @Name.

    Make sure that the Operator list is set to =.

    In the Value field, type 'AdventureWorks2008'.

    Click OK.

    In the Execution Mode list, click On schedule.

    Click Pick and then click OK.

    Select the Enabled check box.

    In the Server restrictions list, make sure the option is set to None.

    Click OK.