• lonhanner (12/19/2012)


    Please Check This query for me.

    CREATE TABLE NEW_DETAILS

    (

    TD_NUM int identity not null,

    TRIP int not null,

    RIDER_NO int not null,

    LNAME nvarchar(20) null,

    FNAME nvarchar(20) null,

    PROV_CON int null,

    APT_TIME time(7) null,

    PKUP_TIME time(7) null,

    TD_REMARKS nvarchar(20) null,

    NEW_RIDER nvarchar(5) null,

    SORT nvarchar(4) null,

    );

    insert into NEW_DETALIS

    (TRIP, RIDER_NO, LNAME, FNAME, PROV_CON, APT_TIME, PKUP_TIME, TD_REMARKS, NEW_RIDER, SORT)

    select TRIP, RIDER_NO, LNAME, FNAME, PROV_CON, APT_TIME, PKUP_TIME, TD_REMARKS, NEW_RIDER, SORT

    FROM TRIP_DETAILS

    If the query is correct and all goes well. That still leaves the problem with geting the sequance numbers in the new column TD_NUM. I have over 80,000 records in the TRIP_DETAILS TABLE. In other words after I exeicute the query I will end up with data in all the column except the new TD_NUM column. How do I get get the data in numeric sequnce in the TD_NUM COLUMN so I will have the FK DATA.

    You will have a value in TD_NUM it is an identity column that does not allow NULL.

    I am pretty sure we can help you with what you are trying to do but you need to provide enough details so that we aren't guessing. What we need is ddl (create table scripts), sample data (insert statements) and desired output based on your sample data. Please see the first link in my signature for best practices when posting questions.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/