I'm trying to create a function, not a new table.
- mistake #1
hardcoding data in a routine code - mistake #2
Implementing relations between entities (title and gender) in conditional procedural code instead of a table - mistake #3.
3 basic mistakes for such a small piece of functionality - looks too much to me.
Do not forget what "Q" in "T-SQL" means - query.
You are supposed to query a data storage, not generate the data on fly.
And yes, using functions in T-SQL is a mistake.
Functions are extremely ineffective in data querying and must be avoided by all means.
_____________
Code for TallyGenerator