Question d’entretien chez Two Sigma

Write an efficient stored procedure to allocate unique integer ids.

Réponse à la question d'entretien

Utilisateur anonyme

16 févr. 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