Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...SQL Query to Display Users and their Profile by RoleSQL Query to Display Users and their Profile by Role
Previous
 
Next
New Post
4/9/2011 12:02 AM
 
Here's something similar to Limno's offering.
Not perfect and there are better ways but not useless either:

SELECT  e.RoleName
        ,a.Username
  ,a.FirstName
  ,a.LastName
  ,a.DisplayName
  ,CONVERT(VARCHAR(50),COALESCE(c.PropertyCategory,'')) + ' :: ' +
   CONVERT(VARCHAR(50),COALESCE(c.PropertyName,'')) + ': ' +
   CONVERT(VARCHAR(3750),coalesce(b.PropertyValue,'')) AS UserProperty
  FROM users a
  JOIN dbo.UserProfile b ON b.UserID = a.UserID
  JOIN dbo.ProfilePropertyDefinition c ON c.PropertyDefinitionID = b.PropertyDefinitionID
  JOIN dbo.UserRoles d ON d.UserID = a.UserID
  JOIN roles e ON e.RoleID = d.RoleID
 ORDER BY e.RoleName, a.UserName, c.PropertyCategory

pmgerholdt
 
New Post
4/9/2011 4:32 AM
 
I created a different view for this, showing properties as real columns (one record per user). Downside: you might need to adjust the view according to the columns you'd like to get. You may download the file from here. Unzip and load into SQL textbox in Host menu. Run as script. execute by calling SELECT * FROM UserFullList.
Feedback welcome :)

Cheers from Germany,
Sebastian Leupold

dnnWerk - The DotNetNuke Experts   German Spoken DotNetNuke User Group

Speed up your DNN Websites with TurboDNN
 
New Post
6/29/2011 4:24 PM
 
Hello Sebastian,
I modified your script and before I run it, I test to make sure I dont have any errors in it.  The section where I have the errors is this:

CREATE FUNCTION dbo.dnn_UserRoleNamesList
(
    -- Add the parameters for the function here
    @portalID    int,
    @userID        int,
    @delimiter  nvarchar(10)
)
RETURNS nvarchar(4000)
AS
BEGIN
    -- Declare the return variable here
    DECLARE @ResultVar nvarchar(4000) = ''
    DECLARE @myName nvarchar(50)
    DECLARE @delim nvarchar(10) = ', '
    DECLARE RoleNames CURSOR LOCAL READ_ONLY FOR
     SELECT R.RoleName FROM dbo.dnn_Roles R INNER JOIN dbo.dnn_UserRoles UR On R.RoleID = UR.RoleID WHERE R.PortalID = @PortalID AND UR.UserID = @UserID;
        OPEN RoleNames
    if  not @delimiter is Null SET @delim = @delimiter
    FETCH NEXT FROM RoleNames
    INTO @myName
    WHILE @@FETCH_STATUS = 0
    BEGIN
      IF Not ISNull(@myName, '') = ''
         SET @ResultVar = @ResultVar + ', ' + @MyName
      FETCH NEXT FROM RoleNames INTO @myName
    END
    CLOSE RoleNames
    DEALLOCATE RoleNames

    if isNull(@ResultVar, '') <> '' SET @ResultVar = Substring(@ResultVar, 3, 4000)
    RETURN @ResultVar
END
GO


I am getting error message:
Msg 139, Level 15, State 1, Procedure dnn_UserRoleNamesList, Line 0
Cannot assign a default value to a local variable.
Msg 139, Level 15, State 1, Procedure dnn_UserRoleNamesList, Line 0
Cannot assign a default value to a local variable.
Msg 137, Level 15, State 1, Procedure dnn_UserRoleNamesList, Line 18
Must declare the scalar variable "@delim".
Msg 137, Level 15, State 2, Procedure dnn_UserRoleNamesList, Line 24
Must declare the scalar variable "@ResultVar".
Msg 137, Level 15, State 2, Procedure dnn_UserRoleNamesList, Line 30
Must declare the scalar variable "@ResultVar".
Msg 137, Level 15, State 2, Procedure dnn_UserRoleNamesList, Line 30
Must declare the scalar variable "@ResultVar".
Msg 137, Level 15, State 2, Procedure dnn_UserRoleNamesList, Line 31
Must declare the scalar variable "@ResultVar".

How do I fix this?

Thanks.
 
New Post
6/29/2011 6:24 PM
 
you can't assign a value to local variable when declaring the variable, so instead of this



DECLARE @ResultVar nvarchar(4000) = ''



do this



DECLARE @ResultVar nvarchar(4000)

Set @ResultVar = ''



and similarly for other variables

as you see, there are no complaints about @myName




pmgerholdt
 
New Post
6/30/2011 11:55 AM
 
Michael Gerholdt wrote:
you can't assign a value to local variable when declaring the variable, so instead of this



DECLARE @ResultVar nvarchar(4000) = ''



do this



DECLARE @ResultVar nvarchar(4000)

Set @ResultVar = ''



and similarly for other variables

as you see, there are no complaints about @myName



 
Thank you Michael, that fixed my errors.  I appreciate your assistance.

 
Previous
 
Next
HomeHomeDevelopment and...Development and...SQL and SQL Ser...SQL and SQL Ser...SQL Query to Display Users and their Profile by RoleSQL Query to Display Users and their Profile by Role


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out