There are several methods you are use. The easiest and most common would be to open the SQL Server Management Studio on the server or your workstation and open the file in that. This is the native editor for editing SQL Server scripts. Then click on the Execute button at the top, or press the F5 key, <CTRL> X, or <CTRL> E. This will run the script against what ever SQL Server you are connected to.
You can also run scripts from the command line by using the sqlcmd command line utility and passing it either the script via the -Q or -q switches (they are different) or the -i switch to give it a file to get the script from.