Solved

SQL and AutoNumber Columns

Posted on 1998-05-20
2
446 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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database 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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now