Insert into syntax

  • INSERT INTO [Advision Changes AD] [ ( advertiser_name [ , advertsr_number [ , primary_address1 [ , primary_address2 ] ] ] ) ]

    select [advertiser_name,advertsr_number,primary_address1,primary_address2 ] from DPRADV_ACCOUNTS

    Where [Advision Changes AD].Advision ID = DPRADV_ACCOUNTS.advertsr_sys_id

    Why do i get an error with this. Please help. Thanks.

  • Don't take those square brackets in the formal syntax description of INSERT in Books Online too literally, but if you insist on using table and column names with spaces (why?), you will need square backets around those names.

    INSERT INTO [Advision Changes AD]

    (advertiser_name, advertsr_number, primary_address1, primary_address2)

    SELECT advertiser_name, advertsr_number, primary_address1, primary_address2

    FROM DPRADV_ACCOUNTS

    WHERE [Advision Changes AD].[Advision ID] = DPRADV_ACCOUNTS.advertsr_sys_id

  • andrewd.smith (12/23/2010)


    Don't take those square brackets in the formal syntax description of INSERT in Books Online too literally, but if you insist on using table and column names with spaces (why?), you will need square backets around those names.

    INSERT INTO [Advision Changes AD]

    (advertiser_name, advertsr_number, primary_address1, primary_address2)

    SELECT advertiser_name, advertsr_number, primary_address1, primary_address2

    FROM DPRADV_ACCOUNTS

    WHERE [Advision Changes AD].[Advision ID] = DPRADV_ACCOUNTS.advertsr_sys_id

    @andrewd.smith, Thank you.

  • Sorry. - I just noticed that this is the Access forum. My comment above assumed it was for SQL Server. However, what I said should hopefully be relevant to Access, though I haven't used Access for years.

  • andrewd.smith (12/23/2010)


    Sorry. - I just noticed that this is the Access forum. My comment above assumed it was for SQL Server. However, what I said should hopefully be relevant to Access, though I haven't used Access for years.

    If you could help. I used this code but it is asking to enter the Account id number. I just want them to match the equal to condition and copy this in the target table.

    Thank you.

  • I'm not sure what you are trying to do. If you are trying to copy column values from one table to another where ID columns in the two tables match, then you might be wanting to do an UPDATE query instead of an INSERT query.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply