Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2002
    Posts
    1

    Question Unanswered: Creating an IDENTITY column in a view

    Is it possible to create an IDENTITY column in a view? I would like to have a column which will always start at 1 and increment 1 for every record in the view.

    Thanks!
    CS

  2. #2
    Join Date
    May 2002
    Location
    Shanghai,China
    Posts
    4

    It is impossible


  3. #3
    Join Date
    Jan 2002
    Posts
    12

    there might be another way

    There might be another way to get what you want. It depends on your data. For example if you have a table that has unique rows you could write something like this:

    SELECT
    COUNT(*) AS ID,
    A.Activity_Type_Ky
    FROM
    Activity_Type AS A
    JOIN Activity_Type AS B
    ON A.Activity_Type_Ky > B.Activity_Type_Ky
    GROUP BY
    A.Activity_Type_Ky

    You could also use a function or stored procedure with a temporary table to get what you want if you are not limited to a view.

  4. #4
    Join Date
    May 2002
    Posts
    3
    I suggest you use a stored procedure to:

    1. create a temporary table that includes the identity column
    2. insert all the records of your view into the temporary table using single T-SQL statement
    3. select * from the temprary table

    in sql server 2000 you don't need to drop the temp table

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •