Can I set category_id when creating a new category

  • Hi,

    Is it possible to set category_id when creating a new category (in 2000) so it will be consistent accross all servers ? I can't find any allusion to it in the doc set.

    Many Thanks,

    A

  • WHat do you mean by category_id ? Is it some application specific number of your database ?

    HTH, Jens Suessmeyer.

    ---

    http://www.sqlserver2005.de

    ---

  • Jens,

    Category_id as in the dbo.categories table

    Thanks,

    Angus

  • Angus,

    Here is an example of what you are looking for.

    CREATE TABLE dbo.Category (CategoryName VARCHAR(250), CategoryId AS CHECKSUM(CategoryName))

    ALTER TABLE dbo.Category ADD CONSTRAINT

       UK_CategoryName UNIQUE NONCLUSTERED (CategoryName)

    INSERT INTO dbo.Category (CategoryName) VALUES('Category 1')

    INSERT INTO dbo.Category (CategoryName) VALUES('Category 2')

    INSERT INTO dbo.Category (CategoryName) VALUES('Category 3')

    SELECT CategoryName, CategoryId FROM dbo.Category

    DROP TABLE dbo.Category

    HTH

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply