In my Database I have a Stored procedure in which i am getting list of all Paid user
Like this
UserID Name StateName StateID SubProductCatName SubProductCatID StartDate EndDate
1 Vishal Delhi (NCT) 80164 Other Adhesives 87045 2013-08-01 00:00:00.000 2013-08-31 00:00:00.000
1 Vishal Goa 80164 Sealants 87046 2013-08-01 00:00:00.000 2013-08-31 00:00:00.000
but i want these information Like This
UserID Name StateName SubProductCatName StartDate EndDate
1 Vishal Delhi (NCT),Goa Other Adhesives,Sealants 2013-08-01 2013-08-31
Initially my stored Procedure was
Alter PROCEDURE [dbo].[spGetAllPaidUserList]
AS
BEGIN
SELECT UPD.UserID ,
UD.Name ,
VT.ValueTypeName AS StateName ,
PT.StateID ,
VT1.ValueTypeName AS SubProductCatName ,
PT.SubProductCategoryID AS SubProductCatID ,
StartDate ,
EndDate
FROM UserPaymentDetail UPD
INNER JOIN PaymentType PT ON UPD.PaymentTypeID = PT.PaymentTypeID
INNER JOIN ValueType VT ON PT.StateID = VT.ValueTypeID
INNER JOIN ValueType VT1 ON PT.SubProductCategoryID = VT1.ValueTypeID
INNER JOIN UserDetail UD ON UPD.UserID = UD.UserID
ORDER BY UPD.UserID
END
Now i have changed it to
ALTER PROCEDURE spGetAllPaidUserList
AS
BEGIN
SELECT UPD.UserID ,
UD.Name ,
Stuff((SELECT '; ' + VT.ValueTypeName FROM ValueType VT
WHERE VT.ValueTypeID=PT.StateID
FOR XML PATH('')), 1, 1, '')
[VT.ValueTypeName],
Stuff((SELECT '; ' + VT1.ValueTypeName FROM ValueType VT1
WHERE VT1.ValueTypeID=PT.SubProductCategoryID
FOR XML PATH('')), 1, 1, '')
[VT1.ValueTypeName],
StartDate ,
EndDate
FROM UserPaymentDetail UPD
INNER JOIN PaymentType PT ON UPD.PaymentTypeID = PT.PaymentTypeID
INNER JOIN ValueType VT ON PT.StateID = VT.ValueTypeID
INNER JOIN ValueType VT1 ON PT.SubProductCategoryID = VT1.ValueTypeID
INNER JOIN UserDetail UD ON UPD.UserID = UD.UserID
where UPD.Enabled=1
ORDER BY UPD.UserID
END
but it Still show the data in same way although I have used xml
can anyone help......