O'Reilly logo

NHibernate 3 Beginner's Guide by Gabriel N. Schenker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – Creating a script to add an index

In this exercise, we want to create a SQL DDL script to add the same index to the Products table as defined in the preceding exercise using the SSMS table designer.

  1. Open the 0001_create_Products_table.sql file we created during the preceding exercises.
  2. At the very end of the file, add a statement to delete the IX_Products_Name index if it already exists. The code is as shown in the following code snippet:
    IF  EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID('Product') AND name = 'IX_Products_Name')
    DROP INDEX IX_Products_Name ON Product
    GO
  3. Add an alternate table statement to add the index to the Products table. Your code should look similar to the following code snippet:
    CREATE UNIQUE ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required