About Me

My photo
a Dynamic and Energetic guy.....

Wednesday, February 24, 2010

SQL Inner Query to get data without a cursor

ProductCode

MinimumLevel

Bonus

1

5

2

1

10

3

1

20

5

2

5

2

3

8

2

3

12

3


SQL Query

select p.ProductCode,

p.MinimumLevel,


(select
top 1 q.MinimumLevel from ProductTable q where q.MinimumLevel > p.MinimumLevel and q.ProductCode = p.ProductCode)
as MaximumLevel,


p.Bonus


from ProductTable p



ProductCode

MinimumLevel

MaximumLevel

Bonus

1

5

10

2

1

10

20

3

1

20

NULL

5

2

5

NULL

2

3

8

12

2

3

12

NULL

3

Wednesday, February 17, 2010

TFS 2010 error when creating team project



This error raised, when the TFS versions are mismatch. That is TFS server version & the TFS Client (Team Explorer).

We had to uninstall previous version of "Team Explorer" & install new version.
(In my case had to uninstall TFS 2010 beta & install TFS 2010 RC)
Then it starts work fine.
Cheers...

Monday, February 15, 2010

Tax Calculation In Srilanka


Summarized Tax Table - Regular Profits from Employment

Monthly remuneration Tax in SriLanka


1. Monthly remuneration up to Rs. 27,184 - Exempt

2. Monthly remuneration exceeding Rs. 27,184 but not exceeding Rs. 63,406

4.6% of monthly remuneration less Rs. 1,250

3. Monthly remuneration exceeding Rs. 63,406 but not exceeding Rs. 78,125

9.2% of monthly remuneration less Rs. 4,167

4. Monthly remuneration exceeding Rs. 78,125 but not exceeding Rs. 97,917
10% of monthly remuneration less Rs. 4,792

5. Monthly remuneration exceeding Rs. 97,917 but not exceeding Rs. 131,250
15% of monthly remuneration less Rs. 9,687


6. Monthly remuneration exceeding Rs. 131,250 but not exceeding Rs. 172,917
20% of monthly remuneration less Rs. 16,250


7. Monthly remuneration exceeding Rs. 172,917 but not exceeding Rs. 214,584
25% of monthly remuneration less Rs. 24,896


8. Monthly remuneration exceeding Rs. 214,584 but not exceeding Rs. 256,250
30% of monthly remuneration less Rs. 35,625

9. Monthly remuneration exceeding Rs. 256,250

35% of monthly remuneration less Rs. 48,437


Tuesday, February 2, 2010

String Split in SQL

Declare @checkedItems varchar(20)

SET @checkedItems ='N,L,D,E'

Declare
@ParsedList table
(
OrderID varchar
)

DECLARE @OrderID varchar(10), @Pos int

SET @checkedItems = LTRIM(RTRIM(@checkedItems))+ ','
SET @Pos = CHARINDEX(',', @checkedItems, 1)

IF REPLACE(@checkedItems, ',', '') <> ''
BEGIN
WHILE @Pos > 0
BEGIN
SET @OrderID = LTRIM(RTRIM(LEFT(@checkedItems, @Pos - 1)))
IF @OrderID <> ''
BEGIN
INSERT INTO @ParsedList (OrderID)
VALUES (CAST(@OrderID AS varchar)) --Use Appropriate conversion
END
SET @checkedItems = RIGHT(@checkedItems, LEN(@checkedItems) - @Pos)
SET @Pos = CHARINDEX(',', @checkedItems, 1)

END
END

select * from @ParsedList

====================================
OUTPUT
====================================
OrderID
N
L
D
E

My Masters