Friday, February 24, 2012

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 .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|||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

No comments:

Post a Comment