Results 1 to 4 of 4
  1. #1
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596

    Insert Into SQL Question.

    I have Insert Into SQL that I use in a function and it works.
    In it I specify the field names in the target Table and the respective Values that I want inserted.

    Is it possible to do a 'generic' insert where I just say something like [pseudo code]:

    Insert Into TableB . . . no field names specified . . .
    In "\\Path\DBName.accdb"
    Everything from TableA where MyDate is Date() -30

    ??

    I want to archive data from several Tables into their Identically-Structured Archive replica Tables in another DB using that Date() - 30 filter.
    I'm thinking of passing the Table Name and its Date Field Name into the SQL without having to pass in a field list for each of the Tables.

    I hope I've explained what I need clearly.



    Thanks!!

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    Per MS:

    When individual columns are not designated, the SELECT table column names must match exactly those in the INSERT INTO table.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Robeen is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Thanks, Paul!
    The target table is cloned from the source table [structure only].
    There was also the issue of key fields . . . [I was repeatedly trying to insert the exact same data because I only have limited data to work with in the development environment right now].
    Plus - there was an auto number field as well.
    Appreciate your help.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,642
    No problem! Can't recall if autonumber field is a problem in Access. It can be done in SQL Server, which I work with most of the time.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. INSERT query: insert new data only
    By drh in forum Access
    Replies: 2
    Last Post: 04-04-2014, 05:31 PM
  2. Replies: 4
    Last Post: 08-25-2012, 07:19 PM
  3. New insert row
    By khparhami in forum Access
    Replies: 5
    Last Post: 09-06-2010, 10:37 AM
  4. SQL Insert into
    By jamin14 in forum Programming
    Replies: 15
    Last Post: 04-01-2010, 12:35 AM
  5. help with insert
    By jamie in forum Access
    Replies: 1
    Last Post: 11-16-2009, 06:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums