Tag Archives: User Defined Function

T-SQL Function to Get the Default Backup Folder

Again, DBA’s are often faced with adhoc backup tasks that shall dump relevant data or log to the existing backup location for all other data/log dumps. Quick way to do so will invovling concatenating dynamic sql commands with the default … Continue reading

Posted in SQL Server, T-SQL Script, User Defined Function | Tagged , | Leave a comment

T-SQL Function to Return Current Timestamp as String

Sometimes, a DBA will have to make adhoc backups and it is ideal that these backup files are named with proper timestamp info. The below function returns current date and time as a string fomartted in ‘yyymmdd_hhmmss’ style:

Posted in SQL Server | Tagged , | Leave a comment

Two Examples of Recursion with T-SQL

T-SQL is very good for dealing with set-based data, but it doesn’t shy away from recursion either. You can use either user defined functions (UDF) or common table expression (CTE) to achieve this and I put up hereunder two examples … Continue reading

Posted in Common Table Expression, Recursion, T-SQL Script, User Defined Function | Tagged , , | Leave a comment