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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Identity column on sql server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-02-09 : 09:41:45
Sarah writes "Hi All,
I would like to know how can I (identity column on SQL server)
auto Sequencing & insert a Record in identity field from ASP?

I'd be thankfull if you explain the answer in step and showing some Examples.

My Emial ID is there.. Awaithing for your response soon.

Thanks in advanced,
sara"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-09 : 09:44:17
If you use Identity column, exclude that in your insert statement so that it will be incremented automatically whenever new row is inserted to the table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

mallier
Starting Member

24 Posts

Posted - 2006-02-09 : 09:55:50
--or u can set identity insert on--

SET IDENTITY_INSERT tablename ON
-- then ur insert statment


cheers,
http://mallier.blogspot.com
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-02-09 : 10:00:11
And dont forget to set it off at the end

SET IDENTITY_INSERT tablename ON
-- then ur insert statment
SET IDENTITY_INSERT tablename OFF



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2006-02-09 : 10:56:01
auto increment ?

the table below has an auto increment value on the MyID column, which starts at 1 and increments with 1.


CREATE TABLE [dbo].[myexample] (
[MyID] [int] IDENTITY (1, 1) NOT NULL ,
[other_columns1] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
)
GO



NOTE: You cant insert an indentity column, unless you set the identity_insert value off as above
Go to Top of Page
   

- Advertisement -