Tuesday, April 17, 2007

Sql Server, remove duplicate records

Sometimes I need to remove duplicates from a table, given a particular column to be checked.

This few lines of transact-sql code will help, I hope:

CREATE TABLE #tmp_tableCleanDup (id int, email varchar(200))
CREATE UNIQUE CLUSTERED INDEX pk ON #tmp_tableCleanDup(ID)
CREATE UNIQUE INDEX removeduplicates on #tmp_tableCleanDup (email) WITH IGNORE_DUP_KEY

BEGIN TRANSACTION

 INSERT #tmp_tableCleanDup
 SELECT e.ID, e.email
 FROM OriginalTable e

 DELETE OriginalTable
 WHERE 1=1
 AND id NOT IN (SELECT id FROM  #tmp_tableCleanDup)

COMMIT TRANSACTION

 DROP TABLE #tmp_tableCleanDup

Monday, April 16, 2007

don't read this.

ok, you're reading. well, I expected this... but please, DO NOT click on this link...

the game you'll reach is reaaaallly addictive... so if you're working now don't click.

the name of the game is Desktop Tower Defense. simple, easy at the beginning, hard to leave when you start.

 

bye! ;-)

Thursday, April 05, 2007

DeepFish, from Microsoft Labs

Still in a closed beta stage, DeepFish is a mobile browser that mixes a server-side elaboration of the web pages in order to render web pages on the mobile screen just as they would be seen on a standard "non mobile" browser.

When you navigate to a page, DeepFish first of all generates (server-side) a sort of screenshot of the needed page, and sends this image to the mobile client; there with some client functionalities like panning and zooming the user will read the page... obviously things like form submission and client caching are present. Take a look at this presentation to understand better.

Wednesday, April 04, 2007

Sharepoint 2003: customize the webparts zones

I know, today we can use the new Microsoft Office Sharepoint Server (MOSS), but there are a lot of Sharepoint 2003 installation around, and recently I had to face some request from a (french, Paris-based) customer that asked me to make some "deep" customizations for their intranet, both in terms of look&feel and of webparts disposition on the page.

This request was both for the Sharepoint Portal pages and for the Windows Sharepoint Services sites and pages.

I'm not discussing here the "layout" modification, maybe I'll collect some good links that explain this task, let's say here that this was in my case solved mainly with some (not so easy) CSS modifications.

Let's focus on the webpart zones disposition, and how it can be changed.

First of all: I assume in all the samples below that your Sharepoint is installed in the default folder on drive C:\, and that you have the english setup (so in the paths you'll see the \1033\ folder, if you have other language packs you will have to deal with other paths).

The standard, "out-of-the-box" placement of the webparts in the page is ok for a lot of us; but sometimes you want to have some particular disposition of the webparts, in order to make a better use of the page space for your particular needs.

To reach this goal you will have to make some HTML coding in some .aspx pages, located in different paths. These paths correspond to the various "kind" of pages that Sharepoint 2003 offers to us: The Sharepoint main pages, the pages for the various Areas, the News pages, the Topics pages... and on and on down to the Windows Sharepoint Sites pages, both the simple and the Multi Page one.

All the .aspx pages you'll want to modify reside under this path:

C:\Program Files\Common Files\Microsoft Shared\Web server extensions\60\Template\1033\

Down that folder you'll find 13 subfolders. Each folder corresponds to a particular "kind" of page template on the Sharepoint portal or in the WSS sites. Below I'll give you a pair of lists that shows this correspondance.

The main file you'll find under the folder (let's say the first, the \SPS folder) is default.aspx.

This file, at run time, is used by Sharepoint as a template that is "filled" with the webparts you'll have decided to place in the various web part "zones". These zones are explicitly defined in the html of the default.aspx page, and have this look:

<WebPartPages:WebPartZone runat="server" Title="loc:Left" ID="Left" FrameType="TitleBarOnly" AllowPersonalization="false"/>

I will not enter in the details of the various tags; here we'll on ly note that the "ID" tag is the one that gives the name you will see in the sharepoint page, when in design mode.

There are many of these WebPartZone already in place in your default.aspx, go and look for them; you'll see that they are inside an html structure that you can easily hack for your needs; you can alse define more WebPartZones around the page, only be careful to give them unique IDs.

The following list shows each SharePoint Portal Server 2003 area or subarea and the corrisponding folder:
- Root site: \SPS folder
- My Site: \SPSMSITE folder
- News: \SPSNHOME folder
- Company News, External News and Press Announcements, and all areas that are under the News area: \SPSNEWS folder
- Site Directory: \SPSSITES folder
- Topics: \SPSTOC folder
- Divisions, Human Resources, Locations, Marketing, Operations, Projects, Resources, Sales, Strategy and Support, and all areas under the Topics area: \SPSTOPIC folder
- Community Template: \SPSCOMMU folder

Then there are some other folders that are relating to the Windows Sharepoint Services side of the coin; the two main folders are:

- \STS: all the pages for the WSS sites
- \MPS: for the Multi Page Template pages under WSS sites

This last one is a little more tricky, because when you modify the default.aspx page... this modifications will show up only in the main page, and not in the various subpages. To have also these pages modified you'll have to edit another page, in the folder:

C:\Program Files\Common Files\Microsoft Shared\web server extensions\60\TEMPLATE\1033\MPS\DOCTEMP\SMARTPGS

The file is named spstd1.aspx. modify and save it... and you're done.

Now: I'm not saying that all this process is easy and safe;  you'll want to have backup copies of all the files you modify, and you'll want to make a lot of experiments before deploying all this in production... but as soon as you make the first test you'll find comfortable with the other.

Hope this helps...

Andrea