This is my main table structure:
The expertise column is a many to many relationship with another table that has a list of available languages. I wanted to have a flattened structure to display all the languages that a person expertise's, so I wrote a stored procedure that stringifies those multiple expertises to fit for each user.
When I called this sp from my wpf application, its not showing the values. I tried the 'preview data' from object browser which showed only one row of my table.
(Expected result:
What is the problem with my approach?
my Sp:
create procedure myView as
Begin
DECLARE @count INT,@finCount INT,@result varchar(50)
SET @result =' '
SET @count = 1
SELECT @finCount=COUNT(*) FROM usersProfile
WHILE (@count <= @finCount )
BEGIN
SELECT @result=@result+langName+','
FROM expertises
INNER JOIN ED_UPD_MERGE on expertises.id=ED_UPD_MERGE.idfrmED
INNER JOIN usersprofile on ED_UPD_MERGE.idfrmUPD=usersprofile.expertiseid
WHERE usersprofile.id =@count
SELECT usersProfile.id,usersProfile.fullname,usersProfile.screename ,usersProfile.age ,usersProfile.address ,usersProfile.emailid1 ,usersProfile.emailid2 ,usersProfile.isActive ,usersProfile.entryCreated ,usersProfile.entryModified ,usersProfile.experience ,roles.rolesName,@result as Expertise
FROM usersProfile
JOIN roles
ON usersProfile.roleid =roles.id
WHERE usersprofile.id =@count
SET @result= ''
SET @count = (@count + 1)
END
End