Moving a row?

Results 1 to 2 of 2

Thread: Moving a row?

  1. #1
    Join Date
    Dec 1969

    Default Moving a row?

    Hello!<BR><BR>Is there any trick to take all information in one row (let&#039;s say with ID 222), and add the information to another database? Or do I have to take the information out the ordinary way and add it? (excluding getting into Access and moving it manually of course)<BR><BR>Thanks in advance.<BR><BR>(Access, ASP)

  2. #2
    Join Date
    Dec 1969

    Default Not too hard...

    You really *do* mean another *database*, not just another table?<BR><BR>I have to wonder about your system design if you have multiple databases that would be sharing the same kind of information. I would *hope* that you would be only using multiple tables.<BR><BR>But I&#039;ll take you at your word, for now:<BR><BR>Assuming you are connected to DB1.mdb and you want to move a row from Table1 to Table2 in DB2.mdb, it looks *something* like this:<BR><BR>INSERT INTO Table2 IN c: hefullpath oDB2.mdb <BR>SELECT * FROM Table1 WHERE id = 222<BR><BR>DELETE FROM Table1 WHERE id = 222<BR><BR>Two steps. You are done. (Leave off the DELETE, of course, if you really need to copy the record instead of move it.)<BR><BR>(And if the two tables are actually in the same database, then you just leave out the "IN dbname" clause.)<BR><BR>Check out the ACCESS docs for INSERT INTO and the IN clause.<BR><BR>Almost forgot...if the fields aren&#039;t named the same (or one table has more fields than the other) then you can be explicit about it:<BR><BR>INSERT INTO Table2 IN c: hefullpath oDB2.mdb <BR>&nbsp; &nbsp; ( field1, field2, field3 )<BR>SELECT ( fieldX, fieldY, fieldZ ) FROM Table1 WHERE id = 222<BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts