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 – 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.
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.
GROUP BY Done Right
GROUP BY Done Right separates row filters from group filters, handles NULL groups, and avoids totals inflated by careless joins.
SQL SERVER – UDF – Validate Integer Function
ISNUMERIC() returns 1 for plus, minus and currency signs, so it is not a safe check. I share the UDF I use to validate integer values instead.
SET_BIT: Return a Changed Value Without Updating Data
SET_BIT returns a value with one bit set or cleared. Compare the default one with explicit zero, and keep scalar calculation separate from updates.
XQuery FLWOR: Filter and Rebuild a Small XML Result
XQuery FLWOR can iterate over source items and construct a different XML result. I use it to filter three products and reorder the survivors. The new elements deliberately differ from the source elements.







