December 2002
Intermediate to advanced
1560 pages
40h 44m
English
The main benefit of user-defined functions is that you are no longer limited to just the functions that SQL Server provides. For example, the getdate() function returns both a date component and a time component, with a time down to the milliseconds. What if you wanted it to return just the date with the time always set to midnight? In that case, you would have to pass the result from getdate() through some other functions to zero out the time component. The following is a possible solution:
select convert(datetime, convert(char(10), getdate(), 110))
Any time you want just the date with the time always set to midnight, you have to perform the same conversion operation. Alternatively, you can create a user-defined ...
Read now
Unlock full access