Executing Transact-SQL scripts on a .mdf file

While playing with Workflow Foundation’s persistence services, I spent hours trying to apply the stock SqlPersistenceService_Schema.sql and SqlPersistenceService_Logic.sql scripts to my standalone SQLEXPRESS .mdf database.  This is actually a “how do I run .sql scripts against any database in VS 2008 with only SQL Express?” question.  The way I’m assuming most people feel their way through database management in Visual Studio is through the Server Explorer window and by adding database items to a project directly.  Unfortunately, neither of these provide an interface for running a Transact-SQL script to populate schema, data, logic, etc.

One of the first answers I found works on the default database format and uses the sqlcmd utility as follows:

sqlcmd -S localhose\SQLEXPRESS -E -Q “create database WorkflowPersistenceDB”

sqlcmd -S localhost\SQLEXPRESS -E -d WorkflowPersistenceDB -i SqlPersistenceService_Schema.sql

sqlcmd -S localhost\SQLEXPRESS -E -d WorkflowPersistenceDB -i SqlPersistenceService_Logic.sql

(For those interested in creating WorkflowPersistenceService databasese, the above scripts are located in C:\Windows\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\EN.  Make sure to run the schema script first.)

I ran into trouble while trying to derive the sqlcmd arguments to target C:\myDatabase.mdf.  Finally, I came across this article that pointed out the Database Project template under Other Project Types in Visual Studio 2008.  Here’s how it goes:

  • Create a new database by adding a Service-based Database item to a project.
  • From the Server Explorer window, right-click on Data Connections and select “Add Connection”.
  • Set “Server name” to ComputerName\SQLEXPRESS.
  • Under “Connect to a database”, select “Attach a database file” and browse to the .mdf file on disk.  Click OK.
  • Add a new project to the solution.  Select “Database Project” under “Other Project Types – Database”.
  • When prompted to Add Database Reference, select the connection that was just added.
  • Add the .sql scripts to the Create Scripts folder, or in general, whichever folder is appropriate.
  • Right-click on the .sql item and select “Run”.

I’m guessing that there are other ways to do this.  Based on the wizard, I’m guessing that there’s a related interface in sqlcmd, something like this or this.  I believe that there’s an easy way to execute .sql scripts from the SQL Server Management Studio as well, if you have a full version of SQL Server.  For those just using Visual Studio, use the Database Project template.

 

Microsoft MIX09 Web Design and Development Conference

It’s well after 2:30am, and, despite many good reasons, I’m finding too preoccupied with MIX09 to sleep.  The Day 1 keynote was apparently enough to send me buzzing around like a sugar-high ferret (multi-tab browsing as fast as my laptop and Internet connection can handle) to download Visual Studio 2008 SP1, the Silverlight 3 Beta, and Blend 3.  Some of the key points that Scott Guthre and others hit on with Silverlight 3 include:

  • Adaptive streaming:  automatically cycled bit-rates on streaming content to provide a responsive user experience and the best quality possible given available bandwidth
  • New codec support for  H.264, AAC, MPEG-4, and custom codecs for your own bitstreams (see Expression Encoder)
  • Improved logging for media analytics
  • Support for IIS Media Services, an integrated HTTP-based media delivery platform (free download)
  • GPU hardware acceleration and HD quality media on the web
  • GPU support for scaling and stretching video
  • Perspective 3D
  • Bitmap/Pixel APIs
  • Pixel shader effects
  • Deep Zoom improvements, including hardware acceleration
  • Deep linking, navigation and SEO
  • Multitouch support
  • 100+ new Controls
  • Library caching support: referenced libraries and assemblies can be downloaded and cached on system, speeding up repeat visits and visits to other sites the use the libraries
  • Data binding improvements
  • Validation error templates
  • Server data push on databound fields
  • Multi-tier REST support
  • New DataForm control
  • Eclipse Support on Mac
  • Out of browser, standalone application support

And in Expression Blend 3:

  • SketchFlow: prototype design tool that handles behaviors and styles with very little code; build flow within application with high-level diagramming; demo to stakeholders using freely redistributable SketchFlow Player; generates document outlines
  • Supports import from Photoshop and Illustrator
  • Integrated revision control support

Microsoft fanboy?  So it would seem.  Evangelist in training?  Definitely.  Sleep-deprived?  Very much so.  More on these topics after a couple software installations and a few REM cycles.

 

WPF Task Tracker

Last spring I took a .NET Tools in C# course and had an opportunity to play around with Windows Presentation Foundation and Visual Studio 2008 a little.   A full description and download link can be found here.  The application is a task list tool that utilizes:

  • LINQ to SQL using a standalone SQL Express database
  • Data Binding of static and dynamic resources
  • Layout controls, data templates, styles, and triggers
  • WPF Command Bindings
  • A lot of XAML, and surprisingly not as much C#
  • A Model-View-Controller architecture
  • Unit tests using the .NET Unit Testing framework
  • Automated build of the solution using a script
 

Free learning resources

Microsoft Dreamspark offers free developer tools such as Visual Studio 2008 Professional and XNA Game Studio to anyone enrolled at a university or high school.  All you have to do is verify your enrollment on their main site or through JourneyEd and then download the tools.

There are also tons of free learning clinics on Microsoft’s E-Learning site.

Finally, for displaced workers, OIT is offering for the Spring 2009 term only free enrollment if you were recently laid off from a full-time job.  Spring term starts this Monday, so hurry!  Here’s the full notice from Chris Maples, President:

———————————————————————————-

Colleagues,

Later today, Tuesday, March 24, OIT and Klamath Community College will have a joint press conference where we will announce the launch of a special, one-time program designed to help open the doors to higher education for recently laid-off Oregonians. The full details of the “Spring Free for Recently Laid-off Oregonians” program, which will be effective for Spring Term 2009 only, will be available after the press release, but I wanted you all to know the germane facts and the underlying reasons for doing this at this time.

First, some facts about this program from the OIT side:

(1) This program is designed to help Oregon residents enter school if they recently lost full-time jobs; consequently, this special, one-time program is limited to people who recently have been laid off from full-time employment

(2) Anyone who is allowed to enroll in a class under this program will have to meet the normal prerequisites and other OIT admissions requirements

(3) This special, one-time program will offer free tuition to recently laid-off workers for the Spring Term 2009 only

(4) This is for the Klamath Falls campus only and does not include any Distance Education Courses

(5) Class enrollment will be limited to available seats only – paying students have priority, there will be no overloads, and no new sections opened

(6) People enrolling through this program will have schedules that are capped at a normal full load (12-13 credit hours)

OIT is in the enviable position of being able to offer a hand to people so they can once again stand on their own two feet. We all know higher education can open doors, so this is our chance to help our fellow Oregonians in these tough times.

There are many reasons for us to do this, and I will touch on several here. First, this is a good thing for us at OIT to do, collectively, as an extended family. We should reach out to people who need assistance now, because irrespective of the challenges that face our university, we should keep in mind that there are people who face even more challenges as individuals than we do as a collective group. Second, many of you have heard me say on numerous occasions that it is critical for us to face coming budget cuts from a position of being positive, moving forward, and avoiding entrenchment mentality – this program allows us to pursue this philosophy. Think of this program as a no-cost vehicle to fill any empty seats in a class with qualified people to introduce them to higher education. Finally, this is a unique, one-time opportunity for OIT to help change the lives of people who may never otherwise get a chance to further their education.

I know that many of you reading this e-mail and seeing the announcement in various news outlets may be working and saving and otherwise making sacrifices to put yourselves through school now. And many of you will not find yourselves being the direct beneficiaries of this program, which is focused on helping people who were in the workforce full time and now find themselves out of a job. I truly wish that we could make such a program more extensive, but we cannot do so without incurring financial liability for an institution where I already have asked some administrative staff to voluntarily take unpaid days off in order to balance the budget for the remainder of this year. This is a one-term opportunity that we are offering in conjunction with KCC for people who will be able to attend class on a space-available basis only. It is being offered out of compassion for people in need.

So, what are the benefits for students, staff, and faculty at OIT? First and foremost, please note that we are mindful that our current students are why we are here now and the reason for OIT’s existence. There will be no additional costs passed on to any of our students as a result of this one-time program. We all are committed to maintaining the highest quality of education available at the most affordable rates possible. This is an approach that may lead to increased enrollment of Oregonians at OIT in the coming year, which may help our overall enrollment and diversity of courses, and is in everyone’s best interest. We have been challenged to be creative about the pending budget cuts, and this approach, which both helps some people who recently have found themselves out of work and provides a possible route toward increasing OIT’s enrollment in the coming year, seems to rise to that challenge.

It is truly a remarkable achievement that this has gone from an idea that was first discussed last Friday morning, March 19, to reality in time for our Spring Term, and everyone who has worked to put this into place has my deepest appreciation and admiration. I feel especially privileged to work at OIT, where we can reach out to try to make a difference and help people improve their lives during these historically challenging economic times. OIT is especially suited to help people get started on the road to re-employment through furthering their education. You all have my deepest appreciation and my fullest commitment to work for an excellent and compassionate OIT.

Sincerely,

Chris

————————————————–
Christopher G. Maples, President
Oregon Institute of Technology

Klamath Falls Office:
3201 Campus Drive
Klamath Falls, OR 97601 USA
Phone: 541.885.1112
FAX: 541.885.1101

Portland-area Office:
20175 NW AmberGlen Ct., Suite 100
Beaverton, OR 97006  USA

————————————————–
Hands-on education for real-world achievement

————————————————–

 

The technology of the DJ

My DJ friend recently suggested that I look into becoming a DVJ for live music performances.  While I hardly have the résumé for it, it does sound like a lot of fun.  Showings such as Daft Punk’s Alive 2007 tour truly inspire, and the technological aspects are quickly drawing me in, let alone the awesome music, lights, and atmosphere of the scene.  Here’s some of the gear (a.k.a. wishlist) that any techno-audiophile can appreciate:

The Pioneer SVM 1000 AV Mixer – Amazing

And accompanying DVJ-1000 DVD turntable

Yamaha’s Tenori-On – Visual Composition on a killer LED panel

Pacemaker – The pocket-sized DJ System

I also wonder what role some additional custom software using WPF, XNA, and maybe a beat detection library might play in the whole scheme of things…

Thanks to Nick for pointing some of these out to me.   Stay sharp, and come home from Iraq safely.

 

Three shall be the number of the counting and the number of the counting shall be three.

Monty Python’s Spamalot in Eugene =)

 

Spring technical electives

Patrick Cauldwell will be teaching an Advanced .NET course at OIT, Beaverton this spring term, starting 3/30/09.   It should show up on the schedule here in the near future, probably as a CST 407.   Also offered will be CST 207 – Game Development w/ Xbox 360, which features an intro to XNA development on the PC and Xbox 360 using C# 2008 and the Torque X Builder.  Both are excellent courses.  If you’re in the Portland area and are a technology student or professional, check them out!

 

Blogging again… for real this time.

My previous WordPress went down, but I have resolved to blog here more often.  Stay tune, and welcome!

In the meantime, the Wiki is still available, as well as an early article, Integrating Subversion with Mantis Bug Tracker using SCMBug.

-Heath