Insert Problem in MS SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dbquery
    New Member
    • Aug 2006
    • 1

    Insert Problem in MS SQL

    hey, I have written a bunch of insert statements and basically all I am trying to do is fill up columns of one table with values from columns of the second table.

    My insert statement looks like:

    INSERT table1(column)
    SELECT column
    FROM table2

    Now, this works for one column , but when I run another statement like this trying to update another column, the second time around it does not work.
    It does not error out, it shows that it runs fine, but the data is not shown on the table. Some of the data which is shown removes the data from the first column in the adjacent row. I am sure I am missing something here, but not able to figure it out, please HELP .
  • moldster
    New Member
    • Jul 2006
    • 18

    #2
    Does your code look like this.

    INSERT INTO Table1
    ( Col1, Col2, Col3.....Etc)
    SELECT col1, Col2, Col3
    FROM Table2

    If not then it won't work. Post your code and I'll have a look

    Cheers
    C

    Comment

    • sumch_tarek
      New Member
      • Aug 2006
      • 3

      #3
      Hi!
      I think you have to do some change.you may use following codes,else email me your total code .Than i heartly solve thats.....
      INSERT INTO Table1
      ( Col1, Col2, Col3.....Etc)
      VALUES(SELECT col1, Col2, Col3.....etc
      FROM Table2)

      Ok....bye
      Last edited by sumch_tarek; Aug 10 '06, 10:52 AM.

      Comment

      Working...