Beyondrelational

Tuesday, April 13, 2010

EXE Files with Open With

Fixing the association settings using Registry editor
Click Start, Run and type Command
Type the following commands one by one:
cd\windows
regedit

If Registry Editor opens successfully, then navigate to the following key:
HKEY_CLASSES_ROOT \ exefile \ shell \ open \ command

Double-click the (Default) value in the right pane
Delete the current value data, and then type:
"%1" %*
(ie., quote-percent-one-quote-space-percent-asterisk.)

Navigate to:
HKEY_CLASSES_ROOT\.exe

In the right-pane, set (default) to exefile
Exit the Registry Editor.

Get Drop Commend to all Procedure & Functions

SELECT 'Drop '+
CASE
WHEN TYPE='P' THEN 'procedure'
ELSE 'function'
END +' '+ NAME FROM sys.all_objects
WHERE TYPE in ('p','fn','tvn')
AND is_ms_shipped=0

Select TOP First from Each Category

Need to write a query for selecting the record in a specific order,
The order is to select top first from each category and then top second from each category and so on…

The actual data is
nId GroupId

1 1
2 1
3 2
4 2
5 1
6 5
7 3
8 4
9 7
10 3
11 2
12 5
13 3
14 1
15 8
16 1
17 4
18 2
19 7

Need the output in the following order
nId GroupId
1 1
3 2
7 3
8 4
6 5
9 7
15 8
2 1
4 2
10 3
17 4
12 5
19 7
5 1
11 2
13 3
14 1
18 2
16 1

Suggest me some ideas to bring the desired output…
--------------------------------------------------------------------------

select nId,GroupId from(
select *,row_number()over(partition by GroupId order by nId) as rn from #table
)t
order by t.rn,t.GroupId,t.nId

Saturday, April 10, 2010

ESS Functions.

Employee Self Service (ESS) Functions:
ESS allows you to access your own HR information such as:
1. Apply leave request
2. Manager leave approval workflow process
3. Apply for Reimbursement.
4. Manager Reimbursement approval workflow process.
5. View your Leave balances and takings and predict future leave balances.
6. View your Reimbursement approval details and how munch of amount Reimbursement approved from the manager.
7. View and modify General, Bank details, Personal Information and change password.

Tuesday, April 6, 2010

Delete Duplicate Values in SQL

Create table TempTable
(
ID INT,
FName nvarchar(50),
LName nvarchar(50)
)
GO
INSERT TempTable Values ('1','XYZ','PQR')
INSERT TempTable Values ('1','XYZ','PQR')
INSERT TempTable Values ('1','XYZ','PQR')
INSERT TempTable Values ('2','ABC','DEF')
INSERT TempTable Values ('2','ABC','DEF')
INSERT TempTable Values ('2','ABC','DEF')
GO

SELECT * FROM TempTable

----

Delete T From
(
Select row_number() over(order by ID) as row_number,* From temptable
)T
Where row_number NOT IN
(
Select min(row_number)row_number from (Select row_number() over(Order by ID desc) as row_number, * From
Temptable)T
group by ID
)
-------------------------

Delete T From
(
Select row_number() over(partition by ID order by ID) as row_number,* From Temptable
)T
Where row_number>1