SDU Tools: Seconds to Duration in T-SQL
There are a few places in T-SQL where instead of a time value, you need to work with a duration.
An example is if I want to sleep for a short period. In T-SQL, we can do that with the WAITFOR statement, used like this:
This command would cause SQL Server to wait for 10 minutes. One of the challenges though, is how do I create this duration string in a programmatic way? For example, how do I create the string ‘00:02:00’ if I’m starting with a value of 120 seconds?
2018-04-04