Feeds:
Posts
Comments

Posts Tagged ‘SQL’

T-SQL Transactions

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 [...]

Read Full Post »

FOR XML and ADO.NET

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’)”, [...]

Read Full Post »

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 [...]

Read Full Post »