sql query for an insert into table

  • tableA ,TableB, tableC , tableD , tableE,

    colA. colb ,colc , colD , colE,

    s, p, d, f, g,

    q, w, r, t , u,

    table 1

    col1,col2,col3,col4,col5,col6,col7,col8,col9,col10

    s,p,d,f,g,X,Y,Z,null,null,

    q,w,r,t,u,X,Y,Z,null,null,

    x , y and z are hard coded ,

    initially table1 has no records

    i need the t-sql to insert records in table 1 and the data inserted should look like the records above (table1) so the records what we are seeing in table one are coming form columns in different tables

    like i have mentioned above

  • Please don't create duplicate threads...

    http://www.sqlservercentral.com/Forums/Topic1212253-392-1.aspx

  • What logic is to be used to decide what row from table(s) b, c,d should be joined to a specific row in tablea to end up with a single row of data taken from the 5 source tables?

    Can you post the fiull DDL of the tables, plus the rules for how to determine what rows to join and this should then be straighforward.

    Mike

  • koolme_85 (11/27/2011)


    tableA ,TableB, tableC , tableD , tableE,

    colA. colb ,colc , colD , colE,

    s, p, d, f, g,

    q, w, r, t , u,

    table 1

    col1,col2,col3,col4,col5,col6,col7,col8,col9,col10

    s,p,d,f,g,X,Y,Z,null,null,

    q,w,r,t,u,X,Y,Z,null,null,

    x , y and z are hard coded ,

    initially table1 has no records

    i need the t-sql to insert records in table 1 and the data inserted should look like the records above (table1) so the records what we are seeing in table one are coming form columns in different tables

    like i have mentioned above

    Do you have any column in Table T1 which is common in all tables ?? If yes, you just need to use joins to write the insert script then.

    It would be nice if you can provide the table structures so that we can answer in better manner.


    Sujeet Singh

Viewing 4 posts - 1 through 3 (of 3 total)

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