Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Serial Data Type

Status
Not open for further replies.

marcela24

Programmer
Feb 17, 2003
72
NL
Is there a serial data type in MS Sql Server?
How is it?
 
What do you mean by a serial data type? Explain the kind of data it contains and maybe we can help you.
 
Sorry, its an increment. It's an id, an int type, automatically incremented.

Hope i made it clear.
 
You can specify an identity attribute for a column. Look it up in BOL.
 
Look up identity in Books online. Here's a sample create table with an identity field as one of the columns.

CREATE TABLE [dbo].[CityLocation] (
[City] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[State] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Latitude] [decimal](10, 3) NULL ,
[Longitude] [decimal](10, 3) NULL ,
[CityLatLonID] [int] IDENTITY (1, 1) NOT NULL ,
[InfoType] [char] (2) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
GO
 
I got it!
create table A
(
id int identity (1, 1),
...
)
 
Yeah, but don't use the column name ID, be more specific like CustomerID or VendorID. You'll thank me for this later when you need to use the IDs from different tables and add foreign keys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top