I am using 2008 R2, which apparently doesn't include the IIF function, so I am trying to create one, partly because it's useful, and partly to learn the syntax in SQL Server. I am getting several errors. Can someone please troubleshoot this? Thanks.
CREATE FUNCTION IIF(@A SQL_Variant, @B SQL_Variant, @C SQL_Variant) RETURNS SQL_Variant AS BEGIN DECLARE @ResultVar SQL_Variant CASE WHEN @A=1 Then Set @ResultVar=@B ELSE Set @ResultVar=@C END RETURN @ResultVar END GO
b