TAman (7/29/2009)
I'm not sure what you are representing when you say "stuff"("stuff"And what does the '00000' represent?
Select *
,stuff(stuff(right('00000' + cast(TimeValue As varchar(6)), 6), 5, 0, ':'), 3, 0, ':') As NewTimeValue
From #test;
STUFF is a function to stuff characters into a string. We prepend 5 zeros to the string to make sure we will always have all 6 characters we need in the string. Then we stuff a colon into the appropriate spaces.
In the sample data I provided, the first value inserted into the table is 00:00:24 (000024). When inserted into a bigint column, the leading zeros will be removed.
If you take the code that I provided and ran it - you would see that it returns exactly what you are looking for.
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs