Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MSaccess Select identity

Posted on 2010-09-01
3
Medium Priority
?
554 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
3 Comments
 
LVL 32

Assisted Solution

by:Daniel Wilson
Daniel Wilson earned 1000 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 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Ready to get certified? Check out some courses that help you prepare for third-party exams.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

971 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