Sloan's profileGranada Coder, C#, Sql S...PhotosBlogLists Tools Help
    7/7/2009

    SQLCMD (Simple Example)

     
     
    Download example HERE. (<< Right-click. "Save (Target) As" usually works best).

    If I haven't mentioned it before, thank you Microsoft for the sqlcmd.exe utility.

    If you are new to sqlcmd or new to the concept of repeatability, below is a simple example.
    It creates 3 databases that are exactly the same except for the database-name.
    Can you say "repeatable" (as in every-single-time-repeatable-and-dependable)?

    If you're still using the GUI in Sql Server Management Studio and doing a "Right-Click"/"Add Database" for than anything for casual development, then please stop.
    It is not repeatable.  It does not promote repeatability for "D-DAY" (that's what I call deployment-day). 
     
    My motto:
    If you cannot deploy your code, your code and hard-work is essentially worthless.
     
    The demo is simple.  A database, one table, and 2 stored procedures.  But the skeleton is there.
     
    The example zip file is a demo example of creating a basic “OrganizationDB” (OrganizationDB01, OrganizationDB02, and OrganizationDB03).

    Again, this is a sqlcmd.exe example of using $(Variable)’s to deploy databases….which emphasizes repeatability but with configurability as well.

    Instructions:

    Unzip the files……….read the README.txt file (the top portion contains setup information).

    If you have ".\SqlExpress" setup as your development environment, you should be able to just click:
    RebuildDatabaseMaster_AllThree.bat
    and it should just work.


    Look at the gif screenshot (in the zip), and compare to your database.

    Then you can look at the README.txt file for explanation about what is happening.

    There are also output log files you can look at (mentioned in the README.txt file) which will provide clues if anything does not work.

     

    After you get it down, you’re essentially (always) one copy/paste/edit (the variable file) and a second copy/paste/edit (the .bat file) away from deploying a new database.

     

     

     ISQLW OSQL << These are the early versions of this tool, FYI.

     

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://sholliday.spaces.live.com/blog/cns!A68482B9628A842A!583.trak
    Weblogs that reference this entry
    • None