• You have just a little problem with this.

    If the column name is not present in the SELECT section, but it's there in the WHERE clause,

    The stored procedure ignore this case.

    With this example:

    CREATE FUNCTION dbo.ufGetUserID (@p_Username varchar(20))

    RETURNS int as

    RETURN (

    SELECT usrID

    FROM TB_usrUser

    WHERE usrName = @p_Username

    )

    The function ufGetUserID is never returning,

    Because you search the column name before the table name !