SqlServerAliases.

ExecuteSqlCommand(ICakeContext, string, string) Method

Summary

Execute any SQL command.
Assembly
Cake.SqlServer.dll
Namespace
Cake.SqlServer
Containing Type
SqlServerAliases

Syntax

public static void ExecuteSqlCommand(this ICakeContext context, string connectionString, string sqlCommands)

Examples

    #addin "nuget:?package=Cake.SqlServer"

    Task("Sql-Operations")
        .Does(() =>
        {
            var connectionString = @"Data Source=(localdb)\MSSqlLocalDb;Initial Catalog=MyDatabase";
            var sqlCommand = "create table [CakeTest].dbo.[CakeTestTable] (id int null)";
            ExecuteSqlCommand(connectionString, sqlCommand);
        });

Attributes

Type Description
CakeMethodAliasAttribute

Parameters

Name Type Description
context ICakeContext The Cake context.
connectionString string The connection string. You may want to specify Initial Catalog. If there are changing parameters, Microsoft.Data.SqlClient.SqlConnectionStringBuilder is recommended to escape input.
sqlCommands string SQL to be executed

Return Value

Type Description
void