Categories
General

Does Extension matter for Creating a database?

We have 3 types of file extensions in SQL Server. MDF, NDF and LDF each one representing Primary, Secondary and Log file respectively. Do you think these extensions are need to be given to the respective files? If your answer is yes then you are wrong. You can give any extension as you like or else you can even interchange these 3 extensions to primary, secondary and log file. Extension plays a important role for us to understand which file is what where as when you attach the db, SQL (by pointing the primary file) knows where the log file and the additional files for the db, it will attach the database without any errors. This is because SQL will check the primary file (which you have pointed) and if its in right format then it will start reading the header page to fetch additional details about other files and attach the database.