<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2008/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <Body>
    <ReportItems>
      <Textbox Name="Textbox1">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>--To Copy the code, right click and export to Word</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>-- FROM: </Value>
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
              <TextRun>
                <Value>https://stackoverflow.com/questions/37114898/how-can-i-get-the-list-of-all-database-name-with-their-username-and-roles-in-t-s/37116656#37116656</Value>
                <Style>
                  <FontStyle>Normal</FontStyle>
                  <FontSize>14pt</FontSize>
                  <FontWeight>Normal</FontWeight>
                  <TextDecoration>None</TextDecoration>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value />
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>DECLARE @DB_USers TABLE
		( DBName sysname
		, UserName sysname null
		, LoginType sysname
		, AssociatedRole varchar(max))
 
INSERT @DB_USers
EXEC sp_MSforeachdb
 
		'
		use [?]
		SELECT 
			''?'' AS DB_Name,
		case prin.name when ''dbo'' then prin.name + '' (''+ (select SUSER_SNAME(owner_sid) from master.sys.databases where name =''?'') + '')'' else prin.name end AS UserName,
		prin.type_desc AS LoginType,
		isnull(USER_NAME(mem.role_principal_id),'''') AS AssociatedRole 
		FROM sys.database_principals prin
		LEFT OUTER JOIN sys.database_role_members mem ON prin.principal_id=mem.member_principal_id
		WHERE prin.sid IS NOT NULL and prin.sid NOT IN (0x00) and</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
              <TextRun>
                <Value xml:space="preserve">
	</Value>
                <Style />
              </TextRun>
              <TextRun>
                <Value>	prin.is_fixed_role &lt;&gt; 1 AND prin.name NOT LIKE ''##%'''
 
SELECT
		TypeOfAudit  AS 'Setting'
	, CONVERT(VARCHAR(50),DBName) AS 'DBName'
	, CONVERT(VARCHAR(50),UserName) AS 'User Name'
	, CONVERT(VARCHAR(50),LoginType) as 'Login Type'
	,
		STUFF(
		(
		SELECT ',' + CONVERT(VARCHAR(500),AssociatedRole)
FROM @DB_USers user2
WHERE user1.DBName=user2.DBName AND user1.UserName=user2.UserName
 
FOR XML PATH('')
)
,1,1,'') AS Permissions_user
FROM @DB_USers user1
GROUP BY TypeOfAudit, DBName,UserName ,LoginType 
ORDER BY DBName,UserName</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                </Style>
              </TextRun>
            </TextRuns>
            <Style />
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox1</rd:DefaultName>
        <Top>1.31056in</Top>
        <Left>0.19667in</Left>
        <Height>10.70834in</Height>
        <Width>10.59167in</Width>
        <Style>
          <Border>
            <Style>Solid</Style>
          </Border>
          <BackgroundColor>LightBlue</BackgroundColor>
          <PaddingLeft>8pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox2">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Database Users Code</Value>
                <Style>
                  <FontSize>18pt</FontSize>
                  <Color>White</Color>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox2</rd:DefaultName>
        <Top>0.08833in</Top>
        <Left>0.19667in</Left>
        <Height>0.35833in</Height>
        <Width>10.59167in</Width>
        <ZIndex>1</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>DarkBlue</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox4">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Go to Main Report</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                  <Color>White</Color>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox3</rd:DefaultName>
        <ActionInfo>
          <Actions>
            <Action>
              <Drillthrough>
                <ReportName>=IIF(First(Fields!ProductMajorVersion.Value, "Version") = 10 and First(Fields!EngineEdition.Value, "ServerProperty") &lt;&gt; 5, "MainReport2008", 
IIF(First(Fields!EngineEdition.Value, "ServerProperty") = 5, Nothing, 
IIF(First(Fields!ProductMajorVersion.Value, "Version") &gt; 10 and First(Fields!EngineEdition.Value, "ServerProperty") &lt;&gt; 5, "MainReport", Nothing)))</ReportName>
              </Drillthrough>
            </Action>
          </Actions>
        </ActionInfo>
        <Top>0.4911in</Top>
        <Left>0.19667in</Left>
        <Height>0.36667in</Height>
        <Width>10.59167in</Width>
        <ZIndex>2</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>DimGray</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox8">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Go to Report Library</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                  <Color>White</Color>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox5</rd:DefaultName>
        <ActionInfo>
          <Actions>
            <Action>
              <Drillthrough>
                <ReportName>ReportLibrary</ReportName>
              </Drillthrough>
            </Action>
          </Actions>
        </ActionInfo>
        <Top>0.90222in</Top>
        <Left>0.19667in</Left>
        <Height>0.36667in</Height>
        <Width>5.27888in</Width>
        <ZIndex>3</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>DimGray</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
      <Textbox Name="Textbox9">
        <CanGrow>true</CanGrow>
        <KeepTogether>true</KeepTogether>
        <Paragraphs>
          <Paragraph>
            <TextRuns>
              <TextRun>
                <Value>Back to the Report</Value>
                <Style>
                  <FontSize>14pt</FontSize>
                  <Color>White</Color>
                </Style>
              </TextRun>
            </TextRuns>
            <Style>
              <TextAlign>Center</TextAlign>
            </Style>
          </Paragraph>
        </Paragraphs>
        <rd:DefaultName>Textbox6</rd:DefaultName>
        <ActionInfo>
          <Actions>
            <Action>
              <Drillthrough>
                <ReportName>DatabaseUsers</ReportName>
              </Drillthrough>
            </Action>
          </Actions>
        </ActionInfo>
        <Top>0.90222in</Top>
        <Left>5.54499in</Left>
        <Height>0.36667in</Height>
        <Width>5.24335in</Width>
        <ZIndex>4</ZIndex>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
          <BackgroundColor>DimGray</BackgroundColor>
          <VerticalAlign>Middle</VerticalAlign>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
          <PaddingBottom>2pt</PaddingBottom>
        </Style>
      </Textbox>
    </ReportItems>
    <Height>12.26333in</Height>
    <Style>
      <BackgroundColor>LightGrey</BackgroundColor>
    </Style>
  </Body>
  <Width>11.07167in</Width>
  <Page>
    <LeftMargin>1in</LeftMargin>
    <RightMargin>1in</RightMargin>
    <TopMargin>1in</TopMargin>
    <BottomMargin>1in</BottomMargin>
    <Style />
  </Page>
  <AutoRefresh>0</AutoRefresh>
  <DataSources>
    <DataSource Name="Local">
      <ConnectionProperties>
        <DataProvider>SQL</DataProvider>
        <ConnectString>Data Source=LocalHost;Initial Catalog=master</ConnectString>
        <IntegratedSecurity>true</IntegratedSecurity>
      </ConnectionProperties>
      <rd:SecurityType>Integrated</rd:SecurityType>
      <rd:DataSourceID>ce63079c-ee5f-4434-832c-047c7b470b5e</rd:DataSourceID>
    </DataSource>
  </DataSources>
  <DataSets>
    <DataSet Name="Version">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>SELECT  SERVERPROPERTY('ProductMajorversion') AS 'ProductMajorVersion'</CommandText>
      </Query>
      <Fields>
        <Field Name="ProductMajorVersion">
          <DataField>ProductMajorVersion</DataField>
          <rd:TypeName>System.Object</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <DataSet Name="ServerProperty">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>SELECT ServerProperty('EngineEdition') AS 'EngineEdition'</CommandText>
      </Query>
      <Fields>
        <Field Name="EngineEdition">
          <DataField>EngineEdition</DataField>
          <rd:TypeName>System.Object</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
  </DataSets>
  <rd:ReportUnitType>Inch</rd:ReportUnitType>
  <rd:ReportID>a8fae2de-9e8b-4db9-9b91-0cb7128e9353</rd:ReportID>
</Report>