Similar situation to Can I visit Schengen countries on a Type-D Schengen Visa? but slightly different.
I just got my Type D visa for Spain because I'm going to be an exchange student in Barcelona next year. I understand from various resources that Type D visa is still allowed to travel within EU, similar to the Schengen tourist visa.
My question is about the first port of entry to EU. I have relatives living in Netherlands and were encouraged by them to visit them first and then leave together to Spain from there. Am I allowed to have Netherlands as my first port of entry if I can prove I will go to Spain as scheduled within a few days? Or do I have to use Spain as my first port of entry? (another use case would be if I travel outside EU when I'm studying, do I have to go to Spain first or can I go to other EU as my port of entry?)
Second question is similar, can I leave EU at the end of my study from the Netherlands instead of Spain?
I understand that answers to both question above would be yes for Schengen tourist visa, but I would underline that I have a Type D Visa