Information générale
Forum:
Microsoft SQL Server
Versions des environnements
SQL Server:
SQL Server 2008
I need to pass a key created using GETDATE() to a procedure that creates a record.
So I have
set @rebate_key_date = convert(varchar,getdate(),21)
set @rebate_key = 'TWEB_AUTO'+
substring(@rebate_key_date,9,2)+
substring(@rebate_key_date,12,2)+
substring(@rebate_key_date,15,2)+
substring(@rebate_key_date,18,2)+
substring(@rebate_key_date,21,3)+'000'
this is sometimes producing duplicate keys
BTW what do you mean by a deterministic function ?
Thanks
>GETDATE() is deterministic function.
>
>Can you explain your code?
>
>MartinaJ
>
>>Hi
>>
>>I'm dealing with a system that in one area uses keys generated keys using GETDATE().
>>
>>This is producing duplicates sometimes.
>>
>>If I select GETDATE() in a loop it returns the same datetime through a lot of iterations . How often is the date and time refreshed and what sort of delay would I need to introduce to ensure I got a new date and time on each key generation.
>>
>>
>>Thanks
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement