Scripting table data in SQL Server 2008R2 and above

As you many of the SQL programmers may already know. In SQL Server, it is possible to prepare and save scripts for database or table schemas. In some cases you may also need to script your data stored in the tables. This is a very simple task but it is possible to miss or forget where it is located and how this was achieved.

Read the rest of this entry »


XSL for Converting Flat XML to Hierarchial XML

Just for the reference of XML, XSL enthusiasts, I will quickly demonstrate how you can convert a flat XML file to a hierarchial XML with nested nodes. When hierarchy is the focus, there can be many different XML structures, but for the sake of simplicity, I have chosen the below example. This example assumes that you have ID, PARENTID and LEVEL attributes in each node, and PARENTID being 0, blank or null means that the employee node is a root node. To achieve this conversion, we have to know the root nodes.

Read the rest of this entry »

XML-XSL Transformations in SQL Server

With the release of Master Data Services (MDS) for SQL Server 2008R2, it is now possible to perform XML transformations on the database server. Even though, it may sound as a bad idea to perform such operations on the database level instead of clientside, one can certainly find useful cases for this functionality.

A database configured with MDS, simply contains some CLR assemblies and UDF functions that make use of these assemblies.

Read the rest of this entry »

Integrating Neo4J with SQL Server

After evaluating several graph databases, I decided to put more emphasis on Neo4J. Neo4J seems to be better documented and has a better REST API than the others. But still, I did not want to move all my relational data to Neo4J and there was actually no need to do so. I only needed the graph functionality of Neo4J to retrieve the user relationships as a resultset and merge it with my good old relational data. So I decided to go on to my evaluation by preparing a small .Net assembly to access Neo4J REST API and make use of the  CLR functionality in SQL Server.

Read the rest of this entry »

Behind the scenes of Social Networking : An introduction to Trees, Graphs and Databases

For the past few years, social networking sites have seriously become part of our daily lives. We are twitting, poking, commenting and sharing a lot more than we did in the last decade. Today, successful social sites like Facebook, Twitter and LinkedIn are each hosting hundreds of millions of users, probably reaching a total of almost one billion users around the world.

Read the rest of this entry »