The Shulchan Aruch · Orach Chayim
אורח חיים קנ״גOrach Chayim 153
Siman 153 of 697 in Orach Chayim — 22 se'ifim
הלכות בית הכנסתLaws of the Synagogue· siman 153
Se’if 1א׳
מֻתָּר לַעֲשׂוֹת מִבֵּית הַכְּנֶסֶת בֵּית הַמִּדְרָשׁ, אֲבָל לֹא מִבֵּית הַמִּדְרָשׁ בֵּית הַכְּנֶסֶת.
The Laws of Building a Synagogue. Containing 22 Se'ifim: One may convert a synagogue into a study hall, but not a study hall into a synagogue.
Se’if 2ב׳
בְּנֵי הָעִיר שֶׁמָּכְרוּ בֵּית הַכְּנֶסֶת, יְכוֹלִים לִקַּח בְּדָמָיו תֵּבָה, דְּהַיְנוּ הֵיכָל שֶׁמְּנִיחִין בּוֹ סֵפֶר תּוֹרָה אוֹ לוּחַ שֶׁמַּעֲמִידִין עָלָיו סֵפֶר תּוֹרָה; מָכְרוּ תֵּבָה, יְכוֹלִים לִקַּח בְּדָמָיו מִטְפַּחַת שֶׁל סֵפֶר תּוֹרָה; מָכְרוּ מִטְפַּחַת, לוֹקְחִין בְּדָמֶיהָ סְפָרִים, דְּהַיְנוּ שֶׁכָּתוּב כָּל חֻמָּשׁ לְבַדּוֹ, וְכֵן נְבִיאִים וּכְתוּבִים; מָכְרוּ סְפָרִים, לוֹקְחִין בִּדְמֵיהֶן סֵפֶר תּוֹרָה, אֲבָל אִיפְּכָא לְהוֹרִידָן מִקְּדֻשָּׁתָן, אָסוּר. וַאֲפִלּוּ אִם קָנוּ בִּקְצָת הַמָּעוֹת דָּבָר שֶׁקְּדֻשָּׁתוֹ חֲמוּרָה, אֵין יְכוֹלִין לְשַׁנּוֹת הַמּוֹתָר לִקְדֻשָּׁה קַלָּה.
Residents of a city that sold a synagogue may use the money to buy an ark - which is a chamber in which they place a Torah scroll, or a plank upon which to put a Torah scroll. If they sold an ark, they may use the money to buy a cover for the Torah scroll; if they sold a cover, they may use the money to buy scrolls - which are ones in which each Chumash (book of the Torah) is written separately - and likewise, [scrolls of] the Prophets and the Writings; if they sold scrolls, they may use the money to buy a Torah scroll. But the opposite - to lower them from their [level] of holiness - is forbidden. And even if they bought something that is more sacred with part of the money, they may not exchange the rest for something less sacred.
Se’if 3ג׳
סֵפֶר תּוֹרָה שֶׁנִּמְצָא בּוֹ טָעוּת, דִּינוֹ כְּחֻמָּשִׁים וְעַיֵּן לְעֵיל סִימָן קמ"ג.
A Torah scroll in which a mistake is found has the status of Chumash scrolls (and see above, siman 143).
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0