Wrox Programmer Forums
|
Reporting Services SQL Server Reporting Services. Please specify which version.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Reporting Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 6th, 2008, 07:23 AM
Authorized User
 
Join Date: Jul 2008
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default merging the records

m having database data as:

employeeid employeename task

1 neha aaaa
2 xyz bbbb
2 xyz cccc
3 abc yyyy
3 abc kkkk
3 abc pppp


i want the output in this form in table

1 neha aaaa
2 xyz bbbb cccc
3 abc yyyy kkkk pppp


m using sql server 2005 reporting services and from the use of stored procedure i get all the fields in a dataset.
i use grouping to employeeid so that distinct values are shown but it doesn't show the second task for a particular id.
please help m.
i will be very thank full to you.


 
Old August 13th, 2008, 12:18 AM
Friend of Wrox
 
Join Date: Oct 2007
Posts: 130
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via AIM to urtrivedi
Default

In mssql2000 i was also encountered same situation and at that time I used cursor to merge record

1) I created stored procedure using cursor
2) Entered merged data into temporary table
3) Returned the result of temp table to user

Problems with this type of report, This makes performance of report very very slow, I had to convince the client not to have this kind of report.

I dont know about sql 2005 that is there any function to concate or merge record or not.

Following is sample code for reference
---------------------------------------------------------------
CREATE PROCEDURE USP_MERGE_EMPTASK
AS

---CREATE TEMP TRANS TABLE
CREATE TABLE #TEMP_TRANS_DETAIL(EMPLOYEEID INT,
            EMPLOYEENAME VARCHAR(250),TASK VARCHAR(1000))

--INSERT EMPLYEES RECORDS INT TEMP TABLE FROM EMPLOYEEMASTER
INSERT INTO #TEMP_TRANS_DETAIL (EMPLOYEEID,EMPLOYEENAME,TASK)
    SELECT B.EMPLOYEEID,B.EMPLOYEENAME,''
    FROM EMPLOYEEMASTER B

DECLARE @EMPLOYEEID INT
DECLARE @TXT VARCHAR(30)

--DECLARE CURSOR
DECLARE MAINCUR CURSOR FOR
SELECT EMPLOYEEID,TASK FROM TRANS_DETAIL ORDER BY EMPLOYEEID--THIS IS ACTUAL TABLE FROM WHERE WE WILL FETCH TASK OF EMPLOYEE ONE BY ONE
OPEN MAINCUR
WHILE (1=1)
BEGIN
    FETCH NEXT FROM MAINCUR INTO @EMPLOYEEID,@TXT
    IF(@@FETCH_STATUS <> 0)
        BREAK
        --UPDATE TEMPORAY TRANSACTION TABLE
        UPDATE #TEMP_TRANS_DETAIL SET #TEMP_TRANS_DETAIL.TASK=#TEMP_TRANS_DETAIL.TASK+@T XT+' '
        WHERE EMPLOYEEID=@EMPLOYEEID

END
CLOSE MAINCUR
DEALLOCATE MAINCUR


SELECT EMPLOYEEID, EMPLOYEENAME,TASK FROM #TEMP_TRANS_DETAIL

GO
---------------------------------------------------------------


urt

Help yourself by helping someone.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging nodes trishla XSLT 11 October 18th, 2007 03:01 PM
Grouping/Merging Jens Rudolph XSLT 2 June 6th, 2007 02:50 AM
Merging files ajindal General .NET 2 January 10th, 2007 06:42 AM
Merging in flex rsshanmugapriya Beginning VB 6 2 December 16th, 2006 01:54 AM
Merging dataset. sanjay_gupta ADO.NET 2 December 30th, 2003 01:56 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.