Execute the following
SQL Server T-SQL script in SSMS Query Editor to create a function for the automatic
generation of daily specials:
-- T-SQL create user-defined scalar-valued function - UDF
CREATE FUNCTION fnRoadsideDinerDailySpecial( )
DECLARE @DailySpecial NVARCHAR(50),
SET @DayOfWeek = UPPER(DateName(dw,getdate()))
IF @DayOfWeek = 'MONDAY'
SET @DailySpecial = 'Chicken breast a''la San Francisco'
IF @DayOfWeek = 'TUESDAY'
SET @DailySpecial = 'Hungarian beef goulash'
IF @DayOfWeek = 'WEDNESDAY'
SET @DailySpecial = 'Almond-crusted scrod with penne pasta'
IF @DayOfWeek = 'THURSDAY'
SET @DailySpecial = 'Hamburger with sauteed mushrooms and onions'
IF @DayOfWeek = 'FRIDAY'
SET @DailySpecial = 'Cajun shrimp New Orleans style'
IF @DayOfWeek = 'SATURDAY'
OR @DayOfWeek = 'SUNDAY'
SET @DailySpecial = 'Sorry no special today'
SELECT DailySpecial = dbo.fnRoadsideDinerDailySpecial()
-- Cajun shrimp New Orleans style