RSS

Sequences in SQL Server 2012

19 Feb

introducation

you can easily generate auto-incrementing numbers With Sequence, it will be a different object which you can attach to a table column while inserting

Creating a Sequence in SQL Server Coding

/****** Create Sequence Object ******/

CREATE SEQUENCE SEquence2012

START WITH 1

INCREMENT BY 2;

/****** Create Table ******/

Create  TABLE Employee

(  ID int NOT NULL PRIMARY KEY,

FullName nvarchar(100) NOT NULL  );

/****** Insert Some Data ******/

INSERT Employee (ID, FullName)

VALUES (NEXT VALUE FOR SEquence2012, ‘Mostafa’),

(NEXT VALUE FOR SEquence2012, ‘Mohamed’),

(NEXT VALUE FOR SEquence2012, ‘Elmasry’);

go

Creating a Sequence in SQL Server Wizerd

 
Leave a comment

Posted by on February 19, 2012 in New Feature

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s