Showing posts from 2005

and finally my company has a web site

My Engagement

yep, today will be my enageement day.

Note To Self

I guess today is going to be a remarkable day in my life

My Birth Day

Just 23 years old.

Microsoft PDC05

Some of the contents released at PDC 05 Atlas: Microsoft platform for AJAX Project LINQ: Avalon/Indigo Application Tags: PDC , PDC05

The Finalizer

These guys went too far...

SQL Server 2005 TSQL Enhancements: PIVOT and UNPIVOT Operators

We all know the old complex SELECT...CASE way of creating cross tab reports in SQL 2005 the new PIVOT operator provides a more readable and easy way to create cross tab reports the general syntax : SELECT * FROM <table_source> PIVOT ( aggregate_function ( value_column ) FOR pivot_column IN ( <column_list>) ) table_alias for example we have a database with these two tables Emps(EmpID,Name,ManagerID,DeptID) Depts(DeptID,DeptName) and we want to create a report that shows for each department the number of employees in each level so the report should look like this DeptName Level1 Level2 Level3 Development Department 1 3 4 Sales Department 1 1 0 first of all we need a query that returns the level of the emplyee we will use a Common Table Expression for this with Emps_CTE (EmpID,Name,DeptID,Level) as ( select EmpID,Name,Emps.DeptID,0 as Level FROM Emps WHERE ManagerID is null Union All Select Emps.EmpID,Emps.Name,Emps.DeptID,Level + 1 FROM Emps Join Emps_CTE ON Emps_

SQL Server 2005 TSQL Enhancements: New APPLY Operator

Suppose you have a query that returns a data set and you want for each row returned you want to invoke a function or query that returns a table (table-valued function or query ), the new APPLY operator allowa you to do this for example if you have a table Employees(EmpID,Name,ManagerID) and you have the following function that takes an Employee id as a parameter and returns a table of employees under this employee and their level in the hierarchy CREATE FUNCTION [dbo].[GetEmps](@EmpID [int]) RETURNS @RES TABLE ( Empid INT , EmpName nvarchar(50), Level INT ) AS begin with Emps_CTE (EmpID,Name,Level) as ( select EmpID,Name,0 as Level FROM Employees WHERE ManagerID is null and EmpID=@EmpID Union All Select Employees.EmpID,Employees.Name,Level + 1 FROM Employees Join Emps_CTE ON Emps_CTE.EmpID=Employees.ManagerID ) INSERT INTO @RES select * FROM Emps_CTE return The following query will return for each employee the employees working under him and their level SELECT Employ

SQL Server 2005 TSQL Enhancements: Common Table Expressions

A CTE is composed of an expression name, optional column list, and a defining query. Once defined, the CTE may be referenced in the executing SELECT, INSERT, UPDATE, DELETE, or CREATE VIEW statement for example: use Northwind; with Customers_CTE as ( select ContactName,CompanyName from Customers ) select * from Customers_CTE the beautiful thing about CTEs is that you can use them to create recursive queries say you have the following table Employees(EmpID,Name,ManagerID) and you want to select each employee and his level in the employees hierarchy (with 0 as the top level) this can be accomplished with the following CTE With Emps_CTE (EmpID,Name,Level) As ( SELECT EmpID,Name, 0 AS Level FROM Employees WHERE ManagerID IS NULL Union All Select Employees.EmpID,Employees.Name,Emps_CTE.Level+1 as Level FROM Emps_CTE join Employees on Emps_CTE.EmpID=Employees.ManagerID ) Select * FROM Emps_CTE Note that the defining query must contain at least two SELECT statements combined by a UNION ALL op

Channel 9's First Birthday

Channel 9 is celebrating its first birthday


"If builders built buildings the way that programmers wrote programs, the first woodpecker that came along would destroy civilization" - Weinberg’s Second Law Dijkstra, A discipline of programming, 1976

Visual Studio For Gamers

Scrolling DataGrid (.Net CF)

this is what i found on the net on how to scroll a data grid //Get a reference to the scroll bars in the data grid VScrollBar vsb = (VScrollBar)grd.GetType().GetField("m_sbVert", BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(grd); HScrollBar hsb = (HScrollBar)grd.GetType().GetField("m_sbHorz", BindingFlags.NonPublic|BindingFlags.GetField|BindingFlags.Instance).GetValue(grd); hsb.Value=hsb.Maximum ; vsb.Value=vsb.Maximum ; if anyone knows how to do the same for a ListView please let me know