Magazines, Books and Articles

Friday, July 18, 2008

Copy database diagrams in SQL Server 2005/2008/2012

To copy database diagrams from database dbA to database dbB, run the following in the Query Analyser:

INSERT INTO dbB.dbo.sysdiagrams
SELECT[name],[principal_id],[version],[definition]
FROM dbA.dbo.sysdiagrams

--SELECT * FROM dbB.dbo.sysdiagrams


[Thanks to Pankaj Saha, a colleague at work, for this code snippet.]

Edit: This also works for SQL Server 2008.

Edit: This also works for SQL Server 2012, Service Pack 4.

Edit: Some other links that could be useful:
http://stackoverflow.com/questions/3310137/sql-server-2005-how-to-copy-a-database-diagram-to-another-server
If you get an error "Cannot insert the value null into column "diagram_id"", check this out: http://social.msdn.microsoft.com/Forums/en-US/sqldocumentation/thread/767de035-5509-4150-af21-8b6752653f05

Thursday, July 3, 2008

Hierarchical Data

A lot of real life data is hierarchical. Some are naturally hierarchical, like a family; others are classifications, like the folders in windows explorer. Either way, this data can be quite complex. Hierarchical data is best represented as a tree because of its ability to present the complexity in an easy to understand manner.

In data driven software, hierarchical data is often stored in a database, and presented in a tree control. Most tree controls will accept XML as data. You can retrieve hierarchical data from most databases in XML format. However the shape of this XML is hardly ever compatible with that required by the tree control, requiring transformation of the data XML to a shape acceptable by the tree control. One approach is to use XSLT to effect this transformation.

This requires the developer to develop an XSLT file. However, many developers find it hard to develop in a declarative language such as XSLT.

In this article, we discuss how to:
1. retrieve hierarchical data from the SQL Server 2005 database as XML data, using Common Table Expressions or CTE.
2. develop an
XSLT to transform this XML into a shape acceptable to the tree controls. We will develop XLSTs for the ASP.NET 3.5 tree control and a custom tree based on the article Advanced UI Design Using XML and XSL. The code download also has an example of an ExtJs tree.

Download the article and the code
here. [Click on the file name and click the Save As button.]

Or,
download the article [http://www.mediafire.com/?jmhcjz9bygm].
Download the code [http://www.mediafire.com/?xmm2xjzmxjv].

Saturday, June 21, 2008

The Singleton and the .NET framework

Taking advantage of the .NET framework, a singleton can be implemented as
follows:


// .NET Singleton
sealed class Singleton
{
private Singleton() {}
public static readonly Singleton Instance = new Singleton();
}

Read the article at http://msdn.microsoft.com/en-us/library/ms954629.aspx

Wednesday, February 6, 2008

Exploring the .NET Configuration Files

It is a headache trying to post code to Blogger. After trying for most of the evening, I gave up.

I have uploaded the article and the code to Mediafire, a free file hosting site. Download the pdf file here [http://www.mediafire.com/?66ek99twzj1] and the code here [http://www.mediafire.com/?70c0h5fddtp].

If you have difficulty downloading these, leave your mail address as a comment and I'll mail them to you.

The article explores:

- the classes that represent the structure of configuration files
- the configuration hierarchy and the Configuration class
- classes used to read from/ write to the configuration file
- how to create custom sections

The code explores the concepts discussed in the article.


Your comments and opinion on the article will be greatly appreciated.

Thursday, January 24, 2008

Keeping up the net presence

Maintaining a presence on the net has not been easy.

I am on Orkut since June 2007. Till recently I lived with 7 scraps. My son discovered me and scrapped "
hey dad....just seven scraps ...thats pretty poor...". Since then - due to greetings for the new year - I crossed 10 scraps..whew...feels like an achievement.

A sister invited me to join Shelfari. Seemed like a good idea - books are something I like. Since then I have been bombarded with mails about how inactive a member I am. A
Shelfari member, Dr.M, sent across a 'lets be friends' request. Not knowing any Dr.M's, I rejected his/her hand of friendship, only to find out later that he was a one time customer.

I have been around on Blogger since October 2006. Signing up was easy.

But I have decided to make amends. Blog I shall - sounds like a new year resolution.