Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
snyder2005
Starting Member
1 Post |
Posted - 2005-04-30 : 09:34:04
|
I have a table which has it's primary key (recnum), defined as an identity field, so this field will be auto-incremented upon each INSERT into the table. Right now, when I attempt an insert, I get the error that I can not insert a row into the table with recnum = NULL. My first thought was that our DBA did not create the table correctly, with this field being an identity field, but he says he has. Is there something I should be doing, in my code, in order to get the database to "auto-increment" my recnum primary key field, prior to doing an instert ? |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-04-30 : 09:50:47
|
| Nothing special. You need to specify the column list (excluding the identity column) ie:insert myTable (intcol2, intcol3)values (10, 20)ORinsert myTable (intcol2, intcol3)select <intcol>, <anotherintcol>from someotherTableIf you want anymore specific help, you should post the DDL of the table as well as the code you're using to perform the insert.Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|