Advertisement

05.10.2008 at 06:27PM PDT, ID: 23392244
[x]
Attachment Details

SQL Server 2k5 Autoincrement Key Field ?

Asked by ChiBella in Programming for ASP.NET, SQL Server 2005

I am used to creating sequences in Oracle and then using the sequence to create a autoincrement key on a table but in SQL Server this doesn't seem as straight forward.  I modified the property of my key field to INT and set the identity specification to 'Y', 1,1.
What else do I have to do to make this work?

I tried inserting data into the table assuming it would work like Oracle, but I get this error:

Msg 515, Level 16, State 2, Line 1
Cannot insert the value NULL into column 'FOO_ID', table 'FOO_SQL.dbo.FOO_MAIN'; column does not allow nulls. INSERT fails.
The statement has been terminated.
Start Free Trial
 
Keywords: SQL Server 2k5 Autoincrement Key F…
 
Loading Advertisement...
 
[+][-]05.10.2008 at 06:39PM PDT, ID: 21541199

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 06:50PM PDT, ID: 21541217

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 06:57PM PDT, ID: 21541231

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 07:05PM PDT, ID: 21541242

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 09:15PM PDT, ID: 21541441

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Programming for ASP.NET, SQL Server 2005
Sign Up Now!
Solution Provided By: nolee
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.10.2008 at 09:48PM PDT, ID: 21541505

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628