Creating A Database by scheduling a Job

  • Hi.,

    I need a help. I have certain number of scripts placed in one folder. Everyday those scripts will be changed. So., I have to test those scripts by creating a Database everyday with the scripts present in folder.

    Is it possible to schedule a job in such a way that., it should automatically create a database and execute the scripts placed in the mentioned folder in the database created.?

    If Yes., Can u please explain?

    Thanks in Advance.,

    Gautham

  • Hi Gautham, which version of windows and SQL server are you using.

    🙂

  • I m using windows 7 and SQL Server 2008 R2.

  • gautham.gn (6/20/2014)


    Hi.,

    I need a help. I have certain number of scripts placed in one folder. Everyday those scripts will be changed. So., I have to test those scripts by creating a Database everyday with the scripts present in folder.

    Is it possible to schedule a job in such a way that., it should automatically create a database and execute the scripts placed in the mentioned folder in the database created.?

    If Yes., Can u please explain?

    Thanks in Advance.,

    Gautham

    Can't a sql job with a combination sql and powershell work for you?

    Step #1 (SQL)

    create database TEST

    blah...blah...blah

    Step #2 (PS)

    $ScriptList = get-childitem -path "c:\sqlscripts\*.sql"

    ForEach ($Script In $ScriptList)

    {

    sqlcmd -d TEST -i $Script.FullName

    blah...blah...blah

    }

  • these scripts in the folder, do they require that a specific database be created/present?

    Or do they require that specific objects are present?

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply