Yesterday we had a script where we needed to get the db field type, and based on this we had to write a description of the field. how
Select ( Case DB_Type When 'I' Then 'Intermediate' When 'P' Then 'Pending' Else 'Basic' End) From DB_table
I suggested writing a db function instead of this case argument, because that would be more reusable. how
Select dbo.GetTypeName(DB_Type) from DB_table
The interesting part: one of our developers said that using a database function would be inefficient , since database functions slower than Case statement . I searched the Internet to find an answer that is better suited in terms of efficiency, but unfortunately I did not find anything that could be considered a satisfied answer. Please enlighten me with your thoughts, which approach is better?
Usman khalid
source share