Scotland voted No on the basis of UK in the EU.
Interesting that Scotland's referendum allowed all residents a vote. And a majority of Scots born in Scotland voted for independence. The No vote was secured from a majority of English and European voters. How will Europeans vote next time?
By contrast the European referendum excluded long term residents from Europe, some who have lived in the country for decades. What would have been the result if all residents including Europeans had been allowed to vote?
Another difference is 16 and 17 year olds were allowed to vote in the Scottish referendum.