tsql - Random number in table SQL Server -


please me

    create table university     (       id int,       firstname nvarchar(100),       lastname nvarchar(100)     ) 

need id automatically taken randomly different numbers. must 10 numbers wihout logic.

example:

5478596256  bob  brown 9852451254  tom  jones 7078596585  jason  sadler 

consider creating unique, sequential id.

create table student (       -- start @ 1 , increment 1       id int identity(1,1) primary key,       firstname nvarchar(100),       lastname nvarchar(100) ) 

another option create uniqueidentifier (guid)

create table student (       id uniqueidentifier not null default newsequentialid() rowguidcol primary key,       firstname nvarchar(100),       lastname nvarchar(100) ) 

personally, sequential id. it's easier debug key if it's simple integer rather unwieldy guid. manually punching in sql testing/debugging frustuarting when having punch in guid , formatting correct. also, sequential id gives way of looking @ record order. may depend on specific application needs. also, sequential id more universal guid. guid of microsoft-ism, , while can stored in other dbs such oracle, order of bytes unique sql server, , doesn't port easily.

also, hunch, sequential integer ids may have better performance indexing.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -