johnkainn
asked on
coalasce unique values
Hello,
I am trying to use coalasce to create a string. There are duplicate values of Name in the table.
If I set Distinct in front then I only get one item. How can I get only unique values in @DepartmentName?
DECLARE @DepartmentName VARCHAR(1000)
SELECT @DepartmentName = COALESCE(@DepartmentName,' ') + Name + ';'
FROM HumanResources.Department
WHERE (GroupName = 'Executive General and Administration')
SELECT @DepartmentName AS DepartmentNames
I am trying to use coalasce to create a string. There are duplicate values of Name in the table.
If I set Distinct in front then I only get one item. How can I get only unique values in @DepartmentName?
DECLARE @DepartmentName VARCHAR(1000)
SELECT @DepartmentName = COALESCE(@DepartmentName,'
FROM HumanResources.Department
WHERE (GroupName = 'Executive General and Administration')
SELECT @DepartmentName AS DepartmentNames
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER