Interacting with SQL Server Databases

INFO

This documentation is for FAKE version 5.0 or later. The old documentation can be found here

FAKE can be used to create, delete, and run scripts against a SQL Server database.

Sample Usage

You need to have some edition of SQL Server installed on the machine running these tasks. Choose an edition from the Microsoft SQL Server Downloads page.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
open Fake.Sql

Target.create "CreateIntegrationTestsDatabase" (fun _ ->
    let connectionString = "Data Source=.;Initial Catalog=DATABASE_NAME;Integrated Security=True;"
    SqlServer.dropAndCreateDatabase connectionString

    let scripts = [ "path/to/create/tables.sql"; "path/to/seed/data.sql" ]
                  |> Seq.ofList

    SqlServer.runScripts connectionString scripts
)
module Seq

from Microsoft.FSharp.Collections
val ofList : source:'T list -> seq<'T>