Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    70

    Unanswered: IDENTITY values in a stored procedure

    Hi All,
    This is my stored procedure

    CREATE PROCEDURE testProc AS
    BEGIN
    CREATE TABLE #tblTest(ID INT NOT NULL IDENTITY, Col1 INT)
    INSERT INTO #tblTest(Col1)
    SELECT colA FROM tableA ORDER BY colA

    END


    This is my simple procedure, I wanted to know whether the IDENTITY values created in #tblTest will always be consistent, I mean without losing any number in between. i.e. ID column will have values 1,2,3,4,5.....
    or is there any chance of ID column having values like 1,2, 4, 6,7,8....

    Please reply...
    qa

  2. #2
    Join Date
    Jan 2004
    Location
    In a large office with bad lighting
    Posts
    1,040
    As long as you don't do any deletes from your temp table, your identity column should remain sequential with no gaps.

    -- This is all just a Figment of my Imagination --

  3. #3
    Join Date
    Jul 2003
    Posts
    70
    Thanks for your quick response.

Posting Permissions

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