How to copy datas into temp tables?

  • How do I copy datas from Table A into TempTableB (exactly same data)?

    I tried the select and insert into statement, it moved all my datas in Table A over, which I don't want to.

    Thanks.

  • Requirement is not clear as such.. but is this what you are looking for?

    SELECT <Your coulmns....n>

    INTO #tableB

    FROM TableA

    ---------------------------------------------------------------------------------

  • i want to copy (duplicate) the data in col (A, B, C) into TempTable. But previously when I wrote the SQL statement Select a,b,c Into #temptable, it shifted all the data over and I can't find the temptable.. 😡

  • Is it possible to paste your query here please?

    ---------------------------------------------------------------------------------

  • select col1,col2,col3 into #TableB

    from TableA

    group by col1,col2,col3

    having count(*)> 1

    select * from #TableB

    now the #TableB table having the duplicate data of the TableA

  • sorry I'm still confused..

    Do I write this in a 'new query'?

    Where will the #tableB appear in?

    Thanks.

  • Table #tableB is a temp table, it will only exist for the length of your connection or until you drop it, whichever comes first. You must refer to it as #tableB. Whether it is a new query is dependent on what you are doing.

    Judging by the questions you might want to spend some time reading Books Online for SQL Server.

    CEWII

Viewing 7 posts - 1 through 6 (of 6 total)

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