I always thought a non-deterministic function was not allowed in a UDF, but GETDATE() works in SQL Server 2005. My UDF finds the day difference from today.
SQL SERVER – T-SQL Script to Insert Carriage Return and New Line Feed in Code
Add a carriage return with CHAR(13) and a New Line Feed with CHAR(10) in T-SQL. Handy for formatting output, dynamic SQL with GO, and saving user text.
SQL SERVER – 2005 – Create Script to Copy Database Schema and All The Objects – Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
A step by step tutorial to create a T-SQL script that can copy database schema and all objects, like stored procedures, functions, triggers, tables and views.
Refactoring a Long Stored Procedure Into Readable Steps
Learn refactoring a long stored procedure with output baselines, named temp tables, dead-code removal, and two-way EXCEPT checks before release.
SQL SERVER – Find Monday of the Current Week
Find Monday of the current week with one line of T-SQL: DATEADD and DATEDIFF with the week part and GETDATE() give you the date.
The SQL Basics Almost Everybody Skips
Revisit SQL basics that change query results: NULL logic, logical processing order, grouped filters, and the difference between two common counts.
SQL SERVER – Find Last Day of Any Month – Current Previous Next
Find the last day of any month with DATEADD and DATEDIFF. One script returns the last day of the previous, current and next month in SQL Server.






