Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 2nd, 2004, 09:53 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default Any code for automatically inserting queries of fi

Is there a way of inserting the query of records from the first database into the second? Because I want to use the second db by deleting records that might be unnecessary.

 
Old September 3rd, 2004, 12:09 AM
Authorized User
 
Join Date: Aug 2004
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to sinapra Send a message via MSN to sinapra Send a message via Yahoo to sinapra
Default

is it MSSQL. You can use stored proc and connect to both the dbs. then you can use the aliases of the DB's to select and insert statements.

I just gave you the outlines, hope this gives you some idea. Stored Proc are the best secured way to write such transactions.

Regards

sinapra
 
Old September 3rd, 2004, 02:46 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Do you mean from one database to the other or from one table to the other within same database(be it access or mssql)? Can you explain more on that?

_________________________
- Vijay G
Strive for Perfection
 
Old September 3rd, 2004, 06:31 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Sorry. I meant from one table to the other. And I use MS Access 2000.

 
Old September 3rd, 2004, 06:38 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Try this.
Code:
Insert into DestinationTableName
Select Column1, Column2,....
from SourceTableName
Where Columnx=ValueX
Where Column1 of Source should match with Column1 or Destination in all aspects(Datatype, Order in which it is created in the table, etc...) Else, it would fail resulting errors.

_________________________
- Vijay G
Strive for Perfection
 
Old September 3rd, 2004, 07:19 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Ok what about the ID column, which is the first column? Do you think it would be a good idea to renumber them, or to use the old numbers?

 
Old September 3rd, 2004, 07:24 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

Is Where Columnx=ValueX to be left as is or do I have to replace them with something?

 
Old September 3rd, 2004, 07:27 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

I got
Microsoft VBScript compilation error '800a0401'

Expected end of statement

/amos3.asp, line 134

Insert into results
------------^


 
Old September 3rd, 2004, 07:35 PM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 240
Thanks: 0
Thanked 1 Time in 1 Post
Default

(4th reply after your reply)

Can I put * instead of naming all the fields?

 
Old September 4th, 2004, 12:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

For your first reply : I would prefer to go with old numbers for the ID column, as that would be easy in case you want to refer/compare to the old table in any case.

For your second reply : That was a sample I posed. In case you want to insert rows based on some criteria, that is how you can use. So you got to replace COLUMNX with your original ColumnName and ValueX with the value, you would like to compare with.

For your 3rd reply : You got to post the entire query here, to look into it and suggest you where you go wrong.

For your 4th reply : You can put * after the SELECT keyword if you would like to port all the columns into the resulting table, else you will have to list them one by one, in the order as desgined in the resulting table.

In case the Resulting table is not created already, you can use
Code:
SELECT COLUMNLIST INTO NEWTABLENAME
FROM OLDTABLENAME WHERE COLUMNAMEX=VALUE
All in BLUE above are subject to change based on your requirement.

SELECT INTO is similar to INSERT INTO except that it creates a newtable as mentioned and then inserts the rows, but INSERT INTO inserts rows into existing table.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatically inserting rows at varied intervals Peskarik Excel VBA 0 August 14th, 2008 02:24 AM
how to adjust the table display for dynamic xml fi Venki XSLT 8 July 10th, 2008 09:53 AM
how to make subroutine code automatically execute dgr7 Beginning VB 6 2 February 24th, 2007 11:20 AM
Modifying The Queries Dialog Box VBA code Ben Horne Access VBA 1 September 26th, 2006 04:22 PM
Make IE use fi resx file smiller ASP.NET 2.0 Professional 1 December 4th, 2005 06:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.