Thursday, April 17, 2008

Problematic Functions!

We have unique dilemma at hand. Two SQL Server 2k5 functions are giving different results;

SP_Columns and Information_Schema.Columns

What could be the reason and how to resolve it? And I thought I was adept with SQL Server! :-D

Submitted by Atif Fasihi

Simple but Tricky :-)

Does the following run for infinity or finite time;

for (uint I = 1 ; I >-1 ; I ++);

Reason your answer


Submitted by Imran Younus

Monday, April 14, 2008

Re: What is wrong with this query?

I received a lot of replies about this query but one man was dead on! There is a reason he is known as the "Babe Jee" of Databases! Abdullah Idris cracked this query in 60 secs flat!

Syntactically, there is nothing wrong with this query however it is very unefficient and the logic does not make any sense. Here is how this query should be written;

SELECT
C.CustomerID, C.CustomerName,
C.CustomerType, C.Address1, C.City,
C.State, S.TotalSales
FROM
Customers C
INNER JOIN
(SELECT
CustomerID, SUM(Sales) as TotalSales
FROM
Sales
GROUP BY
CustomerID) S
ON
C.CustomerID = S.CustomerID