Solved

MSaccess Select identity

Posted on 2010-09-01
3
548 Views
Last Modified: 2012-05-10
Hello folks I've this statment and I need to retrieve the identity after I do an SELECT INTO. Im using UNION ALL

Thanks for any help
SELECT  IDENTITY(int, 1, 1) as aa, * 
INTO newTable
FROM (Table A
UNION ALL
TABLE B)

Open in new window

0
Comment
Question by:nkoriginal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 250 total points
ID: 33577459
please try:

SELECT  @@IDENTITY as aa, * 
INTO newTable
FROM (Table A
UNION ALL
TABLE B)

Open in new window

0
 
LVL 5

Author Comment

by:nkoriginal
ID: 33577569
Thanks.!!
It's works but the column "aa" has a ZERO value.
How I can do to insert in that column (aa) an autoincrement value??

Thanks
0
 
LVL 77

Accepted Solution

by:
peter57r earned 250 total points
ID: 33577920
There isn't any way to specify an autoincrement field inan Access Make-table query.
You would have to run another quer/ execute another SQL string afterwards to Alter the table and column to set the autoincrement property.

ALTER TABLE table_name ALTER COLUMN column_name Counter

Alternativley use a pre-built table which includes an autonumber field, and use delete and append queries instead.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question