inserting distinct values from one table to another table

  • Hi All,

    I have the following table

    Table A

    Col1

    0118F

    0118R

    5678

    0118F

    0118R

    5678

    5678

    5678

    0118F

    0118R

    I want to insert only distinct values of Col1 from table A to another table

    Insert into TableB

    (

    UserName, ProjectName, processdate, Recordprocess, Comments, RecordProcessExt

    )

    values(@UserName, 'Test Project', getDate(), distinct Col1 from Table1, 'Test Comments', distinct col1+ 'TR' from TableA)

    How can I accomplish the above. I need to insert distinct column from TableA to RecordProcess and col1+'Tr' to recordprocessExt.I can do it with cursor. I don't know any other way.

    Also, there are other columns in Table A. I am using sql server 2005.

    any help will be appreciated.

  • Insert into TableB

    (

    UserName, ProjectName, processdate, Recordprocess, Comments, RecordProcessExt

    )

    SELECT DISTINCT @UserName, 'Test Project', getDate(), Col1, 'Test Comments', col1+ 'TR'

    from Table1

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

Viewing 2 posts - 1 through 1 (of 1 total)

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