DMS11X (3/11/2011)
I am a complete SQL NooB:crazy:, I am looking to create a custom GETDATE() and use it as a key...Format: AL= ACTIVITY LOG
AL-MMDDYYYY-1
AL-MMDDYYYY-2
AL-MMDDYYYY-3
and so on...
I need the number 1,2,3... to recycle every 24hrs,
so every new date/day (midnight server time) the number attached to the date would cycle back to 1, then 2, then 3 and so on...
Does that make sense?
Another Example:
AL-01012011-1 = January 1st 2011 entry 1
AL-01012011-2 = January 1st 2011 entry 2
AL-01012011-3 = January 1st 2011 entry 3
-----------------------------------------------
AL-01022011-1 = January 2nd 2011 entry 1
AL-01022011-2 = January 2nd 2011 entry 2
How do I get SQL server to format the date as: AL-MMDDYYYY-#
mmhhh... lets see, you need an increasing number that recycles itself when the day changes; isn't that the time of the day?
If a custom key is needed - not sure this is the case but I can't tell because I do not have details about business specifications - I would go with something like:
YYYYMMDDHHMISS
where
YYYY Year
MM Month
DD Day
HH Hours (24 hours time)
MI Minutes
SS Seconds
Do you need less or more granularity than that?
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.