1. Without using SSMS (SQL Server Management Studio)
sqlcmd -S Servername\InstanceName -i C:\filename.sql -o C:\result.txt
e.g. Suppose file name is info.sql and servername is test (default instance)
a. Copy the file info.sql in C drive.
b. open the cmd shell and paste the command written below
sqlcmd -S test -i C:\info.sql -o C:\result.txt
See the ouptut of the query in the result.txt file created in C drive of the server.
2. Using SSMS
a. Copy the script in the new query.
b. Press CRTL+F
c. Press F5.
Get the result in text file.