• Here is a method that you might want to test to verify it does what you require, and if it does test AGAIN and AGAIN to be certain, before attempting in a production system

    --Code to create your table whose structure is NOT known and to demonstrate a possible path for you.CREATE TABLE Unk(Col1 INT,Col2 VARCHAR(3))

    DECLARE @C INT

    DECLARE @b-2 INT

    SET @C = 1

    SET @b-2 = 1

    WHILE @C < 101

    BEGIN

    INSERT INTO Unk

    SELECT @b-2,'abc'

    SET @b-2 = @b-2 + 1

    SET @C = @C + 1

    END

    -- Now a method to take the data from this unknown structure and insert it into a new table with the same structure

    -- Select from table whose structure is NOT known

    -- Into a new table Note the first select statement

    -- creates a new table which I named Kn

    SELECT TOP(10)* INTO Kn FROM Unk ORDER BY Col1 ASC

    --Check that the NEW table exists and contains the required number of rows

    -- which in this example should be 10

    SELECT COUNT(*) FROM Kn

    -- now rename the old and "new" tables

    sp_RENAME 'Unk','Junk'

    sp_RENAME 'Kn', 'Unk'

    -- now check again

    SELECT COUNT(*) FROM Unk

    Do not drop or delete data from the old existing table (now named Junk) until you are CERTAIN the results are what is required.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]