SQL insert from SQL select

Results 1 to 2 of 2

Thread: SQL insert from SQL select

  1. #1
    Mark Stuart Guest

    Default SQL insert from SQL select

    I need to insert a value that I have just selected out of a database using the following code:<BR><BR> SQLStmt ="SELECT AllTrim(Str(account+3)) as account from Cacct.dbf"<BR> Set RSACC = Connection.Execute(SQLStmt)<BR><BR>I need to insert rsacc("account") into another database. How would I do that?

  2. #2
    Join Date
    Dec 1969

    Default RE: SQL insert from SQL select

    You should be able to do the INSERT with the SELECT all in one pass to the db, as long as the data types match.<BR><BR>e.g.<BR><BR>SQLStmt ="INSERT INTO tabletoinsertto (fieldname) (SELECT AllTrim(Str(account+3)) as account from Cacct.dbf)"<BR>Set RSACC = Connection.Execute(SQLStmt)<BR><BR>For a simplifies example...<BR><BR>INSERT INTO employees (employee_name, employee_salary) (SELECT employee_name, employee_salary FROM new_employess WHERE job_description = &#039ASP Developer&#039 AND salary &#062; 100000)<BR><BR>HTH<BR><BR>Jerry<BR><BR><BR><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