Groups | Blog | Home
all groups > sql server (alternate) > january 2004 >

sql server (alternate) : automatic number problem



kaya_alp NO[at]SPAM hotmail.com
1/13/2004 1:52:50 PM
Hi, i have imported an access database into sqlserver 2000. In access,
i have some table fields which were using automatic number as
datatype. But i see that there is not a datatype in sqlserver like
automatic no. I have to enter id numbers to my tables for each records
automatically. Would anybody help me about solving this problem? Any
joe.celko NO[at]SPAM northface.edu
1/13/2004 9:13:14 PM
[quoted text, click to view]
datatype [sic]. <<

You do not understand SQL or data modeling. Fields are not columns;
tables are not file; rows are not records. The entire concept of a
physical numbering of rows is not relational. Your original design
was wrong and you want to copy it into SQL. Why do you want to do
that again????

Erland Sommarskog
1/13/2004 10:16:57 PM
fatih kayaalp (kaya_alp@hotmail.com) writes:
[quoted text, click to view]

You can assign a column the IDENTITY property:

CREATE TABLE a (a int IDENTITY(1, 1) NOT NULL,

To get idenity value the most recently inserted row, use scope_identity().


--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
Martin Feuersteiner
1/14/2004 1:45:48 PM

Joe, go back in the hole you came from, take an attitude course and then
come back. Not earlier.

[quoted text, click to view]

Erland Sommarskog
1/14/2004 11:37:16 PM
Martin Feuersteiner (theintrepidfox@hotmail.com) writes:
[quoted text, click to view]

Joe on an attitude course? What a waste of time and money! That man is a
hopeless case!

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
Joe Celko
1/14/2004 11:49:21 PM
[quoted text, click to view]
is a hopeless case! <<

I was going to take a Dale Carnegie course, but the restraining order is
still in effect.

--CELKO--
===========================
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, datatypes, etc. in your
schema are.

*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button