It seems you don't have knowledge on creating Stored Procedures. You are saving it as a File but you need to execute it in SQL Server.
Sorry to say but this is Advance Topic which you are attempting and you must first spend time learning basics.
And unfortunately we cannot make you learn through this Platform.
Thus please learn how to use and execute Stored Procedure in SQL Server. There are numerous videos on YouTube.