Update to Narayana Vyas Kondreddi's generate insert script for SQL Server 2012

October 14, 2012 at 3:01 PMWilliam Highfield

If you are like me you like re-using tools that you find extremely simple and easy to use. That is the case with Narayana Vyas Kondreddi’s sp_generate_inserts script for SQL Server 2000, 2005, (works with 2008 yet not documented). So when I installed SQL Server 2012 developer my first item was to re-create all of the system stored procs I have in my toolbox.

Unfortunately running the script from the above link will generate an error because the code references a system stored procedure that no longer exists in SQL Server 2012 master.dbo.sp_MS_upd_sysobj_category.  This stored procedure toggles the system mode feature where any object created while the mode is enabled is flagged as a system object.  Since the undocumented sproc does not exist the script will be created but it will not work properly.

However there is a small update that can be done to the original script to fix the issue.

You need to remove the following lines

--Turn system object marking on
EXEC master.dbo.sp_MS_upd_sysobj_category 1

And replace the following lines

--Turn system object marking off
EXEC master.dbo.sp_MS_upd_sysobj_category 2


EXEC sys.sp_MS_marksystemobject sp_generate_inserts

The script should ruin without any errors and work as it did in the previous versions.

I have emailed the owner of the script so hopefully he will update the script for 2012.

Posted in: Developer Tools

Tags: ,

Some fun at the Winnipeg Code Camp 2012

February 26, 2012 at 9:54 AMWilliam Highfield

Overall the Winnipeg Code Camp 2012 did not disappoint, lots of interesting sessions to be found and even more interesting people.

One cool item was: Sam - the Twitter Aware, Arduino Powered, Traffic Light.  Tyler & Jay talk about Sam: http://www.youtube.com/watch?v=Cj5Jdfo00xI

These were the following sessions I took in, each of them offered something different and were quite enjoyable.

  • ASP.NET MVC vs. Ruby on Rails SMACKDOWN - ROUND 2! (Part 1) (Marc Jeanson & James Chambers)
  • ASP.NET MVC vs. Ruby on Rails SMACKDOWN - ROUND 2! (Part 2) (Marc Jeanson & James Chambers)
  • Git 101: Source Control for the Future (David Alpert)
  • Software Craftsmanship Panel Discussion (David Alpert, Amir Barylko, James Chambers, and others!)
  • Illuminated Integration with Team City and Arduino (Tyler Dueck & Jay Smith)

P.S. the winner of the smack down was RoR by a significant margin.  Both sessions and presenters were very informative and dove into the how each framework handles certain features and "how do you do this" in each framework.

Just want to give a big kudos to the organizers and speakers for putting on another successful code camp as well the folks over at Skullspace for hooking up free Wi-Fi for everyone in attendance.

Posted in: Code Development | IT - Software

Tags: , ,

What I have been up to?

January 7, 2012 at 2:00 PMWilliam Highfield

Just an update on what I have been up to since my last post. For starters I have been putting in some time helping out with the open source project http://www.bugnetproject.com/. For the most part I have been doing slot of refactoring and general cleanup of the code base. I have also have been doing some UI standardization to make the UI more consistent across the different sections of the site.

From the site:

BugNET is an open source issue tracking project built using C# and the ASP.NET platform. The main goals are to keep the codebase simple, well documented, easy to deploy and scalable.

It has been interesting helping out on an open source project along with the other developers and I have enjoyed working on it so far. I got started working on it because the company I work for http://core49.com needed a bug tracking system that would us to track bugs/issues as well we wanted clients to be able to enter issues as well. The first thing I did for the project was update the email template engine to use Xml/Xslt to allow for an easier way to generate some of the issue emails that get sent out.

I look forward to doing more work on the project in the New Year as there are some cool ideas on the drawing board for making it even better.

Posted in: Code Development

Tags: , ,

Type 'ContosoUniversity.DAL.Department' could not be found

September 11, 2011 at 10:00 PMWilliam Highfield

So I was going through the tutorial Handling Concurrency with the Entity Framework in an ASP.NET MVC Application when I encountered this error on step 7 of 10.

Type 'ContosoUniversity.DAL.Department' could not be found. Make sure that the required schemas are loaded and that the namespaces are imported correctly. Near type name, line 1, column 132.

The error is thrown on the following line:

var databaseValues = (Department)entry.GetDatabaseValues().ToObject();

This error is due to a bug in EF 4.1 where you separate the DAL and Model Entities out into different namespaces and is referenced here EF4.1 CodeFirst - entry.GetDatabaseValues() throw EntitySqlException.

To fix this issue I came up with this workaround:

Replace the lines:

var databaseValues = (Department)entry.GetDatabaseValues().ToObject(); 
var clientValues = (Department)entry.Entity;

with the following lines:

var clientValues = (Department)entry.CurrentValues.Clone().ToObject();
var databaseValues = (Department)entry.CurrentValues.ToObject();

 It seems to work ok for simple concurrency checks and it allows you to continue on with the tutorial.


Posted in: Knowledgebase

Tags: , , ,

Converting a DataTable to a Html table

November 20, 2010 at 4:58 PMWilliam Highfield


This post is another common question I see on the ASP.NET forums "How to convert a DataTable to a Html table".  The code uses simple looping through the DataTable’s columns and rows/columns to pull the column names and the row data out.  I use the HtmlTable, HtmlTableRow and HtmlTableCell objects to actually build the table on the fly.  I find this much easier than using a StringBuilder to create the Html.

The code samples in this post can be downloaded using the link at the bottom and were created using Visual Studio 2010.  There are samples for both C# and Visual Basic.NET in the download file as well.

DataTableToHtml.zip (24 kb)

Posted in: Articles | Code Development

Tags: , , ,