954,551 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to move data to table 1 to table2 using the sql statment ?

Hi guys i need help i want to move the existing data from table 1 into table 2 how i need to write the query. I tried the select into statement but it did not work at all. So how to do it . Please help i doing this on the vb6 programming

gingank
Junior Poster
109 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

SELECT INTO Table2 (Field1, Field2, Field3) SELECT Table1.Field1, Table1.Field2, Table1.Field3 FROM Table1

As table2 already exists.


Good Luck

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

SELECT INTO Table2 (Field1, Field2, Field3) SELECT Table1.Field1, Table1.Field2, Table1.Field3 FROM Table1

As table2 already exists.

Good Luck

Why cant move into table1 to table 2 got error in query analyzer
said syntax near error INTO. Here the code:

SELECT INTO staff_badgeTracking (400001, '12345', 'nana') 
SELECT staff_badgeTrackingNew.400001, staff_badgeTrackingNew.12345, staff_badgeTrackingNew.nana FROM staff_badgeTrackingNew
gingank
Junior Poster
109 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

SELECT INTO staff_badgeTracking (Field1Name) SELECT ...

You need to use the name of the field in between those parens without any single ticks ', then it should work for you.


Good Luck

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

SELECT INTO staff_badgeTracking (Field1Name) SELECT ...

You need to use the name of the field in between those parens without any single ticks ', then it should work for you.

Good Luck


still can not work can you write a full example and dun use the fieldname use something real like fieldname1= name or something like that?

gingank
Junior Poster
109 posts since Jun 2009
Reputation Points: 10
Solved Threads: 0
 

SELECT INTO staff_badgeTracking (400001, 12345, nana)
SELECT staff_badgeTrackingNew.400001, staff_badgeTrackingNew.12345, staff_badgeTrackingNew.nana FROM staff_badgeTrackingNew


Good Luck

vb5prgrmr
Posting Virtuoso
1,912 posts since Mar 2009
Reputation Points: 156
Solved Threads: 296
 

To move data use update statement. SET the field values of the data u want to move data from to the field value where u want to move the data to.

asad al
Newbie Poster
1 post since Feb 2012
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You