Tuesday, April 26, 2011

Logic Puzzle – Crossing a Desert




You are currently in one of two towns separated by a desert.
You need to cross the desert to get to the other town.
It takes 6 days to cross the desert, but a single person can carry only 4 days worth of food supply.
You can hire porters to help you carry your food supply, but naturally you want to minimize the costs as much as possible.
What would be the plan that will enable you to cross the desert while paying for the minimum possible number of porter days?


source : http://www.tsqlsolutions.com/

ms sql 2000 - delete non-unique records

The follwing content is copied from :
http://www.codingforums.com/archive/index.php/t-60626.html

test it before use, no refund if it doesnt work or destroys your productiondatabase



-- Declare the variables to store the values returned by FETCH.
DECLARE @accountId varchar(40), @appearances int

-- Get the recordset indicating the AccountId with duplicate entries
DECLARE duplicate_cursor CURSOR FOR
SELECT AccountID, COUNT(AccountID) AS namecount
FROM warehouse
GROUP BY AccountID
HAVING COUNT(AccountID) > 1

-- Open the recordset
OPEN duplicate_cursor

-- Perform the first fetch and store the values in variables.
FETCH NEXT FROM duplicate_cursor
INTO @accountId, @appearances

-- Check @@FETCH_STATUS to see if there are any more rows to fetch.
WHILE @@FETCH_STATUS = 0
BEGIN
-- delete all records for this accountId minus 1
-- Determine how many records must be deleted
SET @appearances = @appearances - 1

-- Limit the result of this delete to the above calculated maximum
SET ROWCOUNT @appearances

-- Execute the delete
DELETE warehouse
WHERE AccountID = @accountId

FETCH NEXT FROM duplicate_cursor
INTO @accountId, @appearances
END

CLOSE duplicate_cursor
DEALLOCATE duplicate_cursor

-- Reset the rowcount limits
SET ROWCOUNT 0
GO

Monday, April 11, 2011

Bookmark of PSD UI templates

http://speckyboy.com/2011/04/11/50-free-psd-ui-kits-and-templates-for-web-designers/