Use the command
The first step: win + r type: cmd command, open a command-line tool
Step two: Enter
sqlcmd -S SERVERNAME -U USERNAME -P PASSWORD -i file.sql
Parameter name: -S server address -U username -P password -i script file path
E.g:
sqlcmd -S DESKTOP-ALO838S -U sa -P 55555 -i C:\Users\Administrator\Desktop\SQLQuery1.sql