Pergunta de entrevista da empresa Two Sigma

Write an efficient stored procedure to allocate unique integer ids.

Resposta da entrevista

Sigiloso

16 de fev. de 2011

CREATEPROCEDURE [dbo].[AllocateUniqueIntIds] AS BEGIN SelectABS(CAST(CAST(NEWID()ASVARBINARY(5))ASBigint))as UniqueIntegerId END Go /* Test the store proc */ Exec [dbo].[AllocateUniqueIntIds] //Not sure if this is the correct answer