Jeff Smith Blog

Random Thoughts & Cartesian Products with Microsoft SQL Server

Top 10 Revisited

My Top 10 Things I Hate About SQL post has been an interesting social experiment, to say the least. I knew I was taking a risk by not clearly stating that it was intended as humor, but I thought it would be funny to just post it to see what kind of responses came back. Read more →

SQL GROUP BY techniques

One aspect of the versatile SELECT statement that seems to confuse many people is the GROUP BY clause. It is very important to group your rows in the proper place. Always push GROUP BY aggregations as far into your nested SELECT statements as possible – if you have a situation in which you are grouping by long lists of columns that are not part of primary keys, you are probably have not structured your query correctly. Read more →

A true MVP

Congratulations to our good friend Alex Papadimoulis over at the asp.net weblogs on his Microsoft MVP award. Well-earned!   Read more →

SQLTeam Dating Advice !

These are actual, unedited SQLTeam post subjects that you also might find in a dating forum: Checking for Date Conflict - How to identify those tell-tale signs that your date isn't going well; bringing your laptop along doesn't usually help Problem with relationships - Usually this is the result of not being able to identify date conflicts Pickup Rate based on effective date - Be sure that all payment rates and the definition of “effective” are agreed upon before picking up your date. Read more →

Top 10 Things I Hate About SQL Server

By an anonymous SQL user (a guest blogger) 1. SQL is too complicated! When I have multiple values in my columns, like "JAN,FEB,MAR" or “15,84,22” , SQL Server just doesn't get it. Read more →

ASP / ADO Pivot Function & Example

(For information about using this code click here.) <%@ Language=VBScript %> <%OptionExplicit%> <html> <head> <metaname=vs_targetSchemacontent="http://schemas.microsoft.com/intellisense/ie5"> <metaname="GENERATOR"Content="Microsoft Visual Studio .NET 7.1"> </head> <body> <% dim con 'ADODB.Connection dim com 'ADODB. Read more →

Northwind sample view

create view PivotTestasselect  o.customerID, c.CompanyName, p.productName, sum(od.quantity) as Qty from  orders o inner join  [order details] od on o.orderID = od.orderID inner join  Products p on od. Read more →

CrossTab Performance Testing

usingSystem; usingSystem.Data.SqlClient; usingSystem.Data; namespaceCSharpConsole { class CrossTabTesting { [STAThread] static void Main(string[] args) { SqlConnection conn; string s; int i; conn = new SqlConnection( "Server=(local);Database=Northwind;uid=xx;pwd=xx"); conn.Open(); Console.WriteLine("Beginning performance test for crosstab techniques. Read more →

Pivot Sample (C#)

privatevoid Sample() {// call this from a form .... SqlConnection conn; SqlCommand com; DataGrid dg = new DataGrid(); dg.Parent = this; dg.Dock = DockStyle.Fill; String SQL = Read more →

Pivot function (C#)

public static DataTable Pivot(IDataReader dataValues, string keyColumn, string pivotNameColumn, string pivotValueColumn) { DataTable tmp = new DataTable(); DataRow r; string LastKey = "//dummy//"; int i, pValIndex, pNameIndex; string s; bool FirstRow = true; Read more →