Skip to content
Advertisement

How can I avoid “stringly typed” code in T-SQL?

Consider some code like

I believe that the technical term for such poor code is “stringly typed”. The key issue in the above code is that decisions are being made based on a string output that the developer needs to type and consistently get correct. If anything goes wrong, the language will be incapable of throwing errors. In a traditional language, the workaround would be to construct some sort of dictionary to handle these cases. What is the idiomatic solution in T-SQL? I don’t like the idea of making a use-once table, but maybe a temp table would be helpful?

Advertisement

Answer

I wouldn’t worry about having a “Use in one place” table. If you still worry about it cluttering up your database, you can use a table variable.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement