Please support our MS SQL advertiser: Programming Forums
Views: 78312 | Replies: 10
![]() |
•
•
•
•
| |
Ok, just to clarify? Replicate autonumber in SQL how? You mean within an SQL function/store procedure or in another coding lanuage (if so which one)?
IDENTITY(x,y) is how you use autonumber in SQL ( x = starting point, and y = increment by)
IDENTITY(x,y) is how you use autonumber in SQL ( x = starting point, and y = increment by)
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: May 2005
Location: Cleveland, OH
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
•
•
•
•
Originally Posted by Paladine
Ok, just to clarify? Replicate autonumber in SQL how? You mean within an SQL function/store procedure or in another coding lanuage (if so which one)?
IDENTITY(x,y) is how you use autonumber in SQL ( x = starting point, and y = increment by)
I just needed to know syntax on how to get an autonumber like column for MS SQL Server. So in your example if my field was "bill" lets say when I set it up in the design table area of SQL server I would enter "bill" in the column name field and then enter numeric in the data type field. Then set up the incrementation in a stored proc? Am I in the ball park here?
Well kind of.
Ok here is the syntax on creating a table in SQL and having an autonumber column
The userID will start a 1, and increment each time you add a new user to the table; automatically
Hope this helps
Ok here is the syntax on creating a table in SQL and having an autonumber column
CREATE TABLE NorthWindUsers
(UserID INT IDENTITY(1,1) NOT NULL,
UserName VARCHAR(50) NOT NULL,
Password VARCHAR(50) NOT NULL)The userID will start a 1, and increment each time you add a new user to the table; automatically
Hope this helps
Assistant Manager, Regional Pharmacy Information Systems
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
TLC Services Website (Under Construction)
Updated : ASP.Net Login Code
•
•
Join Date: Jun 2005
Posts: 12
Reputation:
Rep Power: 4
Solved Threads: 0
•
•
•
•
Originally Posted by Paladine
Well kind of.
Ok here is the syntax on creating a table in SQL and having an autonumber column
CREATE TABLE NorthWindUsers (UserID INT IDENTITY(1,1) NOT NULL, UserName VARCHAR(50) NOT NULL, Password VARCHAR(50) NOT NULL)
The userID will start a 1, and increment each time you add a new user to the table; automatically
Hope this helps
You know, this feature isn't in Oracle as I recently discovered. Is it considered bad to use autoincrementing numbers? Certainly makes it easy to maintain a primary key with little effort. I am just trying to understand in what situation you wouldn't want to use that feature. Obviously Oracle doesn't seem to want you to use it at all.
•
•
Join Date: Jun 2005
Location: Kansas City, Missouri, USA
Posts: 345
Reputation:
Rep Power: 4
Solved Threads: 4
•
•
•
•
Originally Posted by relawson
You know, this feature isn't in Oracle as I recently discovered. Is it considered bad to use autoincrementing numbers? Certainly makes it easy to maintain a primary key with little effort. I am just trying to understand in what situation you wouldn't want to use that feature. Obviously Oracle doesn't seem to want you to use it at all.
I don't know that Oracle thinks it is a bad thing, they just choose to solve the problem a different way--with "sequences". In Oracle, as you may know, a sequence is it's own thing outside of any table. Personally, I wish the databases I work with had both an autonumber/identity and a feature like a sequence. They are both very handy. A sequence can be useful if you need a way to have an id unique across multiple tables or multiple databases.
It's easy enough to code your own sequence-like feature using a one column/one row table and a function, but I assume Oracle's sequence feature is highly optimized to do what it does.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)





Hybrid Mode