Solved

SQL and AutoNumber Columns

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to shrink a transaction log file down to a reasonable size.

863 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

21 Experts available now in Live!

Get 1:1 Help Now