Developers should use sqlcmd to connect to a named instance of Microsoft SQL Server first and after they can run Transact-SQL script file.  A Transact-SQL script file is a text file that can contain a combination of Transact-SQL statements, sqlcmd commands, and scripting variables.  To run the script file, developers should follow the next steps:

C# 8.0 and .NET Core 3.0 – Modern Cross-Platform Development: Build applications with C#, .NET Core, Entity Framework Core, ASP.NET Core, and ML.NET using Visual Studio Code, 4th Edition
ASP.NET Core 3 and Angular 9: Full stack web development with .NET Core 3.1 and Angular 9, 3rd Edition
C# in Depth, 4th Edition

1. Open a command prompt window.

2. In the Command Prompt window, type:

sqlcmd -S server\instance -i C:\script.sql

Where server is SQL server name, instance is SQL instance name and script.sql is Transact-SQL script file.

3. Press ENTER