Skip to main content

Posts

Concatenating row values in a single statement using CROSS APPLY

One more SQL issue, one more solution provided. I feel good about it now ;). I am adding it to my collection because it really helps in reducing the duration to execute the process. It is about a new feature which was introduced way back in SQL 2005. CROSS APPLY . The Scenario: Let me lay down the scenario, I have a table which has some 100 thousand + records. This is a very (deliberately) de normalized table. The structure and contents of the table are as below. ID FirstName Education 1 Vighnesh BSC KUD 1995 2 Vighnesh MSC KUD 1997 3 Vighnesh PHD MIT 2009 4 Mark BCOM KUD 2000 5 Mark MBA IIMB 2008 6 Vicky BE VIT 2008 From the above table, I want to get only distinct records, with the education column concatenated. Something like this… ID FirstName Education 1 Vighnesh BSC KUD 1995 MSC KUD 1997 PHD MIT 2009 4 Mark BCOM KUD 2000 MBA IIMB 2008 6 Vicky BE VIT 2008 This can be achieved with a simple query… SELECT DISTINCT FirstName, CAST(Concat_Education as nvarchar(max)) as Education_...

Working with xml data type in MS SQL server

Previously I had worked with xml data type in SQL 2005. There I was serializing the object in to xml and putting it into xml variable in SQL table. And whenever needed I would pull the xml from SQL table and create an object (deserialize). But recently I was presented with a challenge to manipulate the xml in SQL (T-SQL) itself. In this scenario, xml text was being stored in a table as nvarchar(max). Let’s say the column name is “xmlFrag”. A function was written to return rows based on a set parameter. But for the set parameter, if the result set returns multiple rows, the function would combine the xmlFrag column (from both rows) and return one xml fragment. Below is the example. 1st row of the resultset. Gud Day Biscuits Cashew nuts Honey 2nd row of the resultset. Britannia Marie Wheat Barley Then the function would combine these 2 rows data into one single xml fragmen...

Working with large xml files in c# .net

Working with large (huge) xml files is always a pain in the … The reason? These files can’t be loaded in to memory. On my desktop, where I have 2 gigs memory, I can’t open the file in even notepad. I was presented with a challenge recently to manipulate one such large xml file. The xml file was of 550+ MB. I know many would say I have seen bigger xml files than this. But the heart of the matter is if I can’t open 550+ MB file in notepad or in xmldocument in c#, then I can’t open any file bigger than this. And hence the logic to play with these files would remain same. The scenario: We have an xml file from which we want to remove a single node without removing its children. In the below sample xml fragment, the node has to be removed. The children nodes, must then be attached to ( node’s parent) node. One Two 100.22 GoodDay 3 4 Five 200.09 Cra...

Customizing SharePoint search results web part

In some cases the client does not want to display/see out-of-the-box search results. For example the client wants to have a search functionality only on a specific document library or wants to see all the related links by a particular author. In this case it makes sense to display the search results grouped by author. Below we will try to display the search results web part grouped by author. Step 1. In search centre page(where you have placed search box and search results web part), click on ‘Site Actions’ and ‘Edit Page’. Figure 1. Click on ‘Edit Page’. (Since I have already modified the ‘Search Core Results’ web part, you are able to see group by result.) Step 2. For ‘Search Core Results’ web part, click on ‘modify shared web part’ Figure 2. Click on ‘Modify Shared Web Part’ for ‘Search Core esults’. Step 3. Click on ‘XSL Editor…’ button. Copy all the text available. Now open notepad and paste all the content in it. Save the file as ‘SearchAll.xml’. Figure 3. Click on ‘XSL Edit...

A step-by-step guide to Configuring Forms Based Authentication (FBA) in SharePoint 2007

A STEP-BY-STEP GUIDE TO CONFIGURING FORMS AUTHENTICATION IN SHAREPOINT 2007 Following is a checklist for setting up Forms Authentication in SharePoint 2007 1. Setup the membership data store 2. Add a new user to the membership data store 3. Configure SharePoint Central Administration web.config 4. Configure the SharePoint site's web.config 5. Enable Forms authentication on the SharePoint site 6. Authorize the Forms-based user to access the site 7. Login In this article, we will be using the SQL Server membership provider to authenticate users, but you can use any membership provider that you so choose. The steps involved will be about same, but the specifics of those steps may change depending on your provider. I'm also assuming that you've already installed SharePoint and created the SharePoint site on which you're trying to enable forms authentication. STEP 1: SETUP THE MEMBERSHIP DATA STORE Before you can use the SQL Server membership provi...

Sharepoint search customization - Search-as-you-type (SayT), Find-As-You-Type(FAYT)

I was going through some case studies of search customizations in Sharepoint 2007. I stumbled upon something new!! JQuery for search in sharepoint. That is for implementing 'Search-as-you-type' (SayT) or Find-as-you-Type (FAYT) in sharepoint 2007. It looked so simple and prompted me to give it a try right away. This example uses JQuery and sharepoint web service to get the results for what you are typing. All at client side. No server side code needed. And some of the properties are configurable. Which makes it easier even after you deploy this on production. ;) I implemented it right away, below are some of the screenshots. As soon as you type 3 characters (can be configured), the JQuery will bring out all matching results. You can also use the arrow button (or mouse pointer) and choose the right result and hit enter. Steps to implement Now coming back to the steps for implementing it. It is fairly simple, and can be done in a matter of few minutes. 1. C...

SharePoint (MOSS) AssetPicker (AssetURLSelector) customization

Couple of weeks back I was asked to customize the asset picker to suit client's requirements. The requirement was something like this : there is an ASP.net application running on application server, on click of a button, it should open up the assetpicker from MOSS (SharePoint environment). After the user selects a link and clicks on "OK" button in asset picker, the selected URL must be populated in a label. The challenges faced are related to different server farms of hosted applications. asp.net application is on application server and assetpicker is on SharePoint server. Below are the steps followed to achieve the desired result. 1. CALLINGPAGE.ASPX (this is an plain asp.net application page) This page is part of asp.net application which will be hosted in application farm. This page consists of a “Browse” button on click of which the asset picker will be displayed. To achieve the desired result, we have put an iFrame in the HTML code. This iFrame will not be displayed ...