Showing posts with label autonumber. Show all posts
Showing posts with label autonumber. Show all posts

Friday, March 23, 2012

Newbie question

Hi all,
I need an autonumber field in a table.
I set the following parameters for the field:
data type - int,
identity - yes (not for replication)
identity seed - 1
identity increment - 1
Is this the right thing to do?
TIA
CSharpHi,
You are right.
Thanks
Hri
MCDBA
"CSharp" <smitha@.asianetindia.com> wrote in message
news:OMXoyYuFEHA.3180@.TK2MSFTNGP12.phx.gbl...
> Hi all,
> I need an autonumber field in a table.
> I set the following parameters for the field:
> data type - int,
> identity - yes (not for replication)
> identity seed - 1
> identity increment - 1
> Is this the right thing to do?
> TIA
> CSharp
>

Monday, February 20, 2012

Newbee Table question

I am an MS Access developer who is writing his first SQL
Server app.
In MsAccess we have the AutoNumber data type to give
records a unique sequential value. There doesn't appear to
be an equivalent type in SQL Server.
I am adding records from a ASP.Net web page. What would be
the conventional means of giving each new record a
sequential value? I have gotten around this by querying
the table to find the value in the last record then adding
1 to it. I can't believe that there isn't a neater way to
achieve this.You can use something called an "identity" column:
CREATE TABLE #Table (SomeValue VARCHAR(20), AutoNum INT IDENTITY(1,1))
INSERT #Table VALUES ('A')
INSERT #Table VALUES ('B')
INSERT #Table VALUES ('C')
SELECT * FROM #Table ORDER BY SomeValue
A 1
B 2
C 3
"Ian Pendlebury" <anonymous@.discussions.microsoft.com> wrote in message
news:696f01c405c1$3a868d20$a601280a@.phx.gbl...
> I am an MS Access developer who is writing his first SQL
> Server app.
> In MsAccess we have the AutoNumber data type to give
> records a unique sequential value. There doesn't appear to
> be an equivalent type in SQL Server.
> I am adding records from a ASP.Net web page. What would be
> the conventional means of giving each new record a
> sequential value? I have gotten around this by querying
> the table to find the value in the last record then adding
> 1 to it. I can't believe that there isn't a neater way to
> achieve this.
>|||What is to be done in Sql Server to have an autonumber field
****************************************
******************************
Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET
resources...|||Look at the IDENTITY() function
--
Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org
"saurabh" <s_saur79@.yahoo.co.in> wrote in message
news:OzSjUpaEEHA.3408@.tk2msftngp13.phx.gbl...
> What is to be done in Sql Server to have an autonumber field
> ****************************************
******************************
> Sent via Fuzzy Software @. http://www.fuzzysoftware.com/
> Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...