?
Solved

SQL and AutoNumber Columns

Posted on 1998-05-20
2
Medium Priority
?
476 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
[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
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

Get MongoDB database support online, now!

At Percona’s web store you can order your MongoDB database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card. Handle your MongoDB database support now!

Question has a verified solution.

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

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.
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…
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.
Suggested Courses

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