I do not confess to being a database expert, nor a guru in T-SQL, which is why I have only just found out how crap transactions in T-SQL on SQL Server 2000 can be. Take a look at the following piece of T-SQL: CREATE TABLE #Foo ( PK int NOT NULL ) CREATE TABLE #Foo2 [...]
Posts Tagged ‘SQL’
T-SQL Transactions
Posted in Everything, Software Development, tagged Code, SQL on December 8, 2005 | 2 Comments »
FOR XML and ADO.NET
Posted in Everything, Software Development, tagged Code, SQL on August 1, 2005 | 1 Comment »
My esteemed colleague Sahil Malik has blogged about using FOR XML in SQL server. The following C# example demonstrates how to retrieve XML data from a SQL Server 2K5 database as XML: using (SqlConnection conn = new SqlConnection(“…”)) { using (SqlCommand cmd = new SqlCommand( “select’Rob’ as [Employee/@EmployeeName],’A cool dude’ as [Employee] FOR XML PATH(‘Staff’)”, [...]
Common Table Expressions
Posted in Everything, Software Development, tagged Code, SQL on May 20, 2005 | Leave a Comment »
Today I was delighted to learn about common table expressions in SQL Server 2005. Essentially, CTEs replace the need for cursors when executing statements against rows in a result set. Here are some examples… Let us assume that we have an employee table, and the employee table lists all employees in the company. Each employee [...]