SQL Server Mentalist


Home | Pages | Archives


BISQL # 51 : SQL Server Denali Feature # 2 – Sequence number –All Explanation !!

August 30, 2011 10:29 am

Continuing from my last post where u have explained Denali Feture – FileTable :

BISQL # 49 : SQL Server Denali Feature # 1–FileTables #1 – Introduction & Theory

BISQL # 50 : SQL Server Denali Feature # 1- FileTables # 2 – Demo and Scripting Through !!

Today we are looking into sequence number concept

Introduction to sequence number

Some of the feature of sequence number :

Why Should I Used it if I have Identify property with me ?

  1. The application requires a number before the insert into the table is made.
  2. The application requires sharing a single series of numbers between multiple tables or multiple columns within a table.
  3. The application must restart the number series when a specified number is reached. For example, after assigning values 1 through 10, the application starts assigning values 1 through 10 again.
  4. The application requires sequence values to be sorted by another field. The NEXT VALUE FOR function can apply the OVER clause to the function call. The OVER clause guarantees that the values returned are generated in the order of the OVER clause’s ORDER BY clause.
  5. An application requires multiple numbers to be assigned at the same time. For example, an application needs to reserve five sequential numbers.
  6. Requesting identity values could result in gaps in the series if other processes were simultaneously issued numbers.
  7. Calling sp_sequence_get_range can retrieve several numbers in the sequence at once.
  8. You need to change the specification of the sequence, such as the increment value.

What are the Various components od Sequence Number

image

How I am going to Create Sequence ?

image

Drop Sequence object

DROP SEQUENCE 
    { [ database_name . [ schema_name ] . | schema_name. ]    
    sequence_name } [ ,...n ]
     [ ; ]

Most of the keywords are self-explanatory, and from a comparison of syntax you

can see that SQL Server and Oracle are pretty similar in terms of the syntax.

Following are few example for same

create sequence MyFirstSequence as integer
start with 1
increment by 1
minvalue 1
maxvalue 10000

Points to Note :

Content you might be interested more

We will have review on some more topics on Denali !!

Hope this helps !!

Thanks for reading my blog !!

For more interesting links and daily update please subscribe our link resource website

Todays link are follows:

Link Resource # 20 : Aug 26 – Aug 28 « Dactylonomy of Web Resource

Posted by Vishal Pawar

Categories: Query, SQL

Tags:

Leave a Reply



Mobile Site | Full Site


Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.