Good Link Summary

I found a fellow Houston developer that posts a great weekly link summary. Rhonda, thanks for the mention, and I hope to meet you at the next .NET User’s Group!

http://rtipton.wordpress.com/2008/01/13/weekly-link-post-24/

Microsoft IT Advisory Council

So I get a lot of email from Microsoft, which is mostly by my own doing since I like to get the download notifications, my company is a gold partner, etc. Recently I received an email inviting me to fill out an application to join the Microsoft IT Advisory Council.   A while later I learned that I was accepted and have been spending some time browsing the site and the forums provided for discussions.  At first, I thought is was just another means to pump free demographic data out of me, but it does appear to be legit. Apparently there are small meetings to discuss topics relevant to IT professionals.  Here is the blurb from the website describing the concept.


What is the IT Advisory Council?

The IT Advisory Council is a select group of IT Professionals and Developers, which purpose is to share your views, ideas and opinions, helping Microsoft shape future initiatives. As a member, you will play an integral part in providing us with feedback on Microsoft customer offerings, licensing, support, marketing materials and community initiatives.

Members will communicate with us via an online portal and a program of face-to-face and online events. Each event is currently limited to 12 members to ensure rich discussion and you will be eligible to participate based on a point-system on our portal. Membership also involves completing a monthly online ‘task’, which can be completing a mini-survey or sharing your experiences on our portal forums and blogs to help Microsoft understand what it’s like to be in your shoes.

Presently, there are more than 200 members in New York, Chicago, Toronto and the UK, and we are currently opening up further membership both in current locations and worldwide. Do you want to become a Council Member? Register here.


Anyone have any knowledge or experience with this? I am going to check it out and see what kind of resources it may provide and hopefully make some more mutually beneficial connections in the software community.

The Automatic DBA

You know, there is nothing like a painfully long set of SQL scripts that need to be applied to multiple databases to get the creative juices flowing. As I stared at a list of 29 scripts that needed to be applied to at least 2 different databases (it could be much worse), I thought to myself, “There has to be a better way”. SQL Server Management Studio (SSMS) is a great tool, but I do hate how it makes you login to the database with each script you open. What is even worse, when I tried to open all 29 scripts at once it somehow spawned 7 different instances of SSMS in no apparent logical manner. Time to do some research.

I have used SQLCMD in the past, and I knew this would be the source of my enlightenment. SQLCMD is the 2005 command line successor to OSQL for SQL Server 2000. It allows you to execute SQL scripts at the command line. Nice.

Without any further banter, I’ll explain how you too can shave potential hours off of your DBA tasks. Note, this is a SQL Server specific tactic. I’m sure there is a way to do it in Oracle as well, but you’ll have to find some other chum to feed you that.

  1. Pick a folder to consolidate your .sql scripts (ie C:\AutoDBA)
  2. Create a text file called RunDBScripts.bat with the following contents
    DEL %1.%2.log
    REM == LOOP THROUGH ALL SCRIPTS AND RUN THEM, APPENDING TO LOG FILE
    FOR %%f in (*.sql) DO sqlcmd -S %1 -d %2 -i %%f >> %1.%2.log
    pause
  3. Create a second file called RunDBScripts.SERVER.DATABASE.bat (replacing SERVER and DATABASE with your specifics)
    RunDBScripts.bat SERVER DATABASE
  4. Execute the file created in step 3

That’s it, seriously. Try it out and you’ll be amazed and the time it can save you! You’ll also have a nice log file with the output results of the scripts.

The work is really done in the script created in step 2.  You loop through all files based on the *.sql wildcard.  For each file, it will issue the SQLCMD passing in the server, database, and file name.  The >> pipes the output to a log file.  Windows Authentication will be used by default, but you can also modify this to specify a username and password.

If anyone has any schnazzy additions to run from a UNC path or add a timestamp to the logfile name those would be worthwhile additions.

Thanks to these links for help in getting to this solution:

http://vadivel.blogspot.com/2007/11/sqlcmd-part-ix-batch-files.html
http://www.cs.ntu.edu.au/homepages/bea/home/subjects/ith305/description.html
http://technet.microsoft.com/en-us/library/ms180944.aspx