An object prefix adds a type-indicating string to a database object name, such as tbl_, sp_, fn_, or v_. It may seem to make object types immediately recognizable, but repeated prefixes slow visual scanning for developers, business intelligence developers, and administrators. section 2.3
Mistake: naming every object by type
In the MagicChoc SalesDB, tbl_customers and v_customers identify a table and view through their names. However, SQL Server already separates them in Object Explorer, and sys.objects returns their type descriptions. The prefix adds parsing work without improving identification. section 2.3
Prefer these checks before adopting prefixes:
- Use Object Explorer categories to distinguish tables, views, and other objects. section 2.3
- Query sys.objects when code needs an object's type. section 2.3
- Rename existing objects carefully when removing prefixes; dependent views and procedures require deliberate handling. section 2.3
Listing 2.7 Returning the customers objects
SELECT
name
, type_desc
FROM sys.objects
WHERE name LIKE '%customers%' ;
Inspect matching object names and their SQL Server types with a sys.objects query. section 2.3
