Solved

SQL and AutoNumber Columns

Posted on 1998-05-20
2
452 Views
Last Modified: 2006-11-17
When using JDBC to insert into a database, how does one cope with AutoNumber Columns. What sort of SQL statement should I use?

I've tried leaving the autonumber field off - error: 'Number of query values and destination fields aren't the same'
setting the field to null - error: 'You tried to assign the Null value to a variable that isn't a Variant data type.'

I suppose that I could look up the last number each time and set the value accordingly, but this seems a little unsatisfactory.
0
Comment
Question by:binkle
2 Comments
 
LVL 7

Accepted Solution

by:
spiridonov earned 20 total points
ID: 1089953
>Number of query values and destination fields aren't the same'
From the error you getting it seems that you are leaving the filed off only in INSERT OR SELECT/VALUES part of the statement
you should not mention it at all in your insert statement. This field is handled by SQL server automatically.
0
 

Author Comment

by:binkle
ID: 1089954
Yeah - pretty dum heh?
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

777 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