You must Sign In to post a response.
  • Category: SQL Server

    Insert query from one table to another table

    I have two table like below
    Table 1
    uid hour
    1 8am
    2 9am
    3 10am
    4 10am
    5 11am
    6 11am
    7 11am

    Table2 --I need a query to insert value from above table like below value.
    h8am h9am h10am h11am 12am..
    1 1 2 3 0
  • #761637
    Hi Sankar.

    What is your requirement? I didn't get what you are asking about.
    Can you elaborate so that we can provide you the exact query.


    Sridhar Thota.
    If you learn't from defeat..
    You haven't really lost..

    Sridhar Thota.
    Editor: DNS Forum.

  • #761645
    Following is your required query. Enjoy :)

    INSERT INTO [dbo].[Table_2]
    ( SELECT count(*) as Col1, hour
    FROM [Test11].[dbo].[Table_1] group by hour)

    By Nathan
    Direction is important than speed

  • #761653

    What about Table2 columns...?

    For example if Table1 Contains n no of rows under column hours, then how do you insert into Table2.?

    Please elaborate your requirement and share your table structure..

    Hope you got my point...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • Sign In to post your comments