Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert data from table1 to table2 1

Status
Not open for further replies.

tekthis

MIS
Jun 9, 2004
77
US
hi...i have created a form where users enter data then their info is sent to a tempusers_tbl...a page is displayed showing what they have entered; if they agree they submit the info and the data should transfer to the users_tbl from the tempusers_tbl...i am using ACCESS as my db and ASP as the scripting lang...here is what i have...

DIM sSQL

sSQL = "Insert into users_tbl select name from (select name from tempusers_tbl tb where NOT EXISTS " & _
"(select null from users_tbl where name = tb.name))"

...this doesn't want to work...

thanks for you time...
 
Something like this ?
sSQL = "Insert into users_tbl select name from tempusers_tbl tb where tb.name NOT IN (select name from users_tbl)"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thank you for your reply...it still seems that it doesn't want to work...here is my code from beginning to end...
----------------------------------------------------------
<% @ Language="VBScript" %>
<% Option Explicit %>

<html>
<head><title>4.Insert MAIN DB 1 </title></head>
<body>
<%
Dim connection
Dim name
Dim sSQL
Dim sConnString

sSQL = "Insert into users_tbl select name from tempusers_tbl tb where tb.name NOT IN (select name from users_tbl)"

Set connection = Server.CreateObject("ADODB.connection")

sConnString="DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=" & Server.MapPath("users.mdb") & ";"

Connection.Open sConnString

connection.execute(sSQL)

connection.Close
Set connection = Nothing
%>
Thanks...
</body>
</html>

-------------------------------------------------------
thanks again for your time...
 
And what about this ?
sSQL1 = "Delete from tempusers_tbl where name IN (select name from users_tbl);"
sSQL2 = "Insert into users_tbl select name from tempusers_tbl;"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
the insert worked perfectly....thank you...the only thing i did was put ()'s around name...im still working on the delete statement...that still is giving me some trouble...thanks again for your help...
 
BTW, Try to avoid using reserved words like Date, Name, Table, ... for columns or tables names.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top