Compartir vía


Uso de informes personalizados con propiedades de nodo del Explorador de objetos

Se aplica a:SQL ServerAzure SQL DatabaseInstancia administrada de Azure SQLAzure Synapse AnalyticsAnalytics Platform System (PDW)Punto de conexión de SQL Analytics en Microsoft FabricAlmacén en Microsoft FabricBase de datos SQL en Microsoft Fabric

Los informes personalizados se pueden ejecutar en el contexto de un nodo del Explorador de objetos seleccionado si los informes personalizados hacen referencia a los parámetros de informe de ese nodo. Este contexto permite que un informe personalizado use el contexto actual, por ejemplo, la base de datos actual o una base de datos o un objeto de servidor.

Parámetros de informe del nodo del Explorador de objetos

Nombre del parámetro Tipo de dato
ObjectName string
objectTypeName string
filtrado booleano
ServerName string
FontName string
DatabaseName string

Ejemplo de parámetros de informe de nodo del Explorador de objetos

Para ejecutar el ejemplo, use el procedimiento siguiente.

Ver los valores de los parámetros de informe de un nodo en el Explorador de objetos

  1. Copie el código de ejemplo siguiente en un nuevo archivo de texto y asigne un nombre al archivo mediante una extensión .rdl.

  2. Copie el archivo de informe en una carpeta que creó en el servidor de bases de datos para informes personalizados.

  3. En Management Studio, haga clic con el botón derecho en un nodo en el Explorador de objetos, seleccione Informes, seleccione Informes personalizados. En el cuadro de diálogo Abrir archivo , busque la carpeta informes personalizados y seleccione el archivo de informe y, a continuación, seleccione Abrir.

    Cuando se abre un nuevo informe personalizado por primera vez desde un nodo del Explorador de objetos, el informe personalizado se agrega a la lista usada más recientemente en Informes personalizados en el menú contextual de ese nodo. Cuando se abre un informe estándar por primera vez, también aparece en la lista usada más recientemente en Informes personalizados. Si se elimina un archivo de informe personalizado, la próxima vez que se seleccione el elemento, aparecerá un mensaje para eliminar el elemento de la lista usada más recientemente.

    1. Para cambiar el número de archivos que se muestran en la lista usada recientemente, en el menú Herramientas , seleccione Opciones, expanda la carpeta Entorno y, a continuación, seleccione General.

    2. Ajuste el número de Mostrar archivos en la lista usada recientemente.

Ejemplo de código de informe personalizado

El informe que se crea mediante el código siguiente usa los parámetros asociados a un nodo del Explorador de objetos.

<?xml version="1.0" encoding="utf-8"?>
<Report xmlns="http://schemas.microsoft.com/sqlserver/reporting/2005/01/reportdefinition" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
  <ReportParameters>
    <ReportParameter Name="ObjectName">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <AllowBlank>true</AllowBlank>
      <Prompt>ObjectName</Prompt>
    </ReportParameter>
    <ReportParameter Name="ObjectTypeName">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <AllowBlank>true</AllowBlank>
      <Prompt>ObjectTypeName</Prompt>
    </ReportParameter>
    <ReportParameter Name="Filtered">
      <DataType>Boolean</DataType>
      <Nullable>true</Nullable>
      <AllowBlank>true</AllowBlank>
      <Prompt>Filtered</Prompt>
    </ReportParameter>
    <ReportParameter Name="ServerName">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <AllowBlank>true</AllowBlank>
      <Prompt>ServerName</Prompt>
    </ReportParameter>
    <ReportParameter Name="FontName">
      <DataType>String</DataType>
      <DefaultValue>
        <Values>
          <Value>Tahoma</Value>
        </Values>
      </DefaultValue>
      <AllowBlank>true</AllowBlank>
      <Prompt>FontName</Prompt>
    </ReportParameter>
    <ReportParameter Name="DatabaseName">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <DefaultValue>
        <Values>
          <Value>master</Value>
        </Values>
      </DefaultValue>
      <AllowBlank>true</AllowBlank>
      <Prompt>DatabaseName</Prompt>
    </ReportParameter>
  </ReportParameters>
  <DataSources>
    <DataSource Name="AllReportParameters">
      <ConnectionProperties>
        <IntegratedSecurity>true</IntegratedSecurity>
        <ConnectString>Data Source=.</ConnectString>
        <DataProvider>SQL</DataProvider>
      </ConnectionProperties>
      <rd:DataSourceID>f1feee4c-0fdc-4301-9efa-3cd89eed2d9f</rd:DataSourceID>
    </DataSource>
  </DataSources>
  <BottomMargin>1in</BottomMargin>
  <RightMargin>1in</RightMargin>
  <rd:DrawGrid>true</rd:DrawGrid>
  <InteractiveWidth>8.5in</InteractiveWidth>
  <rd:SnapToGrid>true</rd:SnapToGrid>
  <Body>
    <ReportItems>
      <Textbox Name="textbox1">
        <rd:DefaultName>textbox1</rd:DefaultName>
        <ZIndex>1</ZIndex>
        <Width>6in</Width>
        <Style>
          <PaddingLeft>2pt</PaddingLeft>
          <PaddingBottom>2pt</PaddingBottom>
          <FontFamily>Tahoma</FontFamily>
          <FontWeight>700</FontWeight>
          <FontSize>20pt</FontSize>
          <Color>SteelBlue</Color>
          <PaddingRight>2pt</PaddingRight>
          <PaddingTop>2pt</PaddingTop>
        </Style>
        <CanGrow>true</CanGrow>
        <Height>0.36in</Height>
        <Value>AllReportParameters</Value>
      </Textbox>
      <Table Name="table1">
        <DataSetName>AllReportParameters</DataSetName>
        <Top>0.36in</Top>
        <Details>
          <TableRows>
            <TableRow>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="ObjectName">
                      <rd:DefaultName>ObjectName</rd:DefaultName>
                      <ZIndex>5</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Parameters!ObjectName.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="ObjectTypeName">
                      <rd:DefaultName>ObjectTypeName</rd:DefaultName>
                      <ZIndex>4</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Parameters!ObjectTypeName.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="Filtered">
                      <rd:DefaultName>Filtered</rd:DefaultName>
                      <ZIndex>3</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Parameters!Filtered.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="ServerName">
                      <rd:DefaultName>ServerName</rd:DefaultName>
                      <ZIndex>2</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Parameters!ServerName.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="FontName">
                      <rd:DefaultName>FontName</rd:DefaultName>
                      <ZIndex>1</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Parameters!FontName.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="DatabaseName">
                      <rd:DefaultName>DatabaseName</rd:DefaultName>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>=Parameters!DatabaseName.Value</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
              <Height>0.21in</Height>
            </TableRow>
          </TableRows>
        </Details>
        <Header>
          <TableRows>
            <TableRow>
              <TableCells>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox2">
                      <rd:DefaultName>textbox2</rd:DefaultName>
                      <ZIndex>11</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <FontWeight>700</FontWeight>
                        <FontSize>11pt</FontSize>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <BackgroundColor>SteelBlue</BackgroundColor>
                        <Color>White</Color>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>ObjectName</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox3">
                      <rd:DefaultName>textbox3</rd:DefaultName>
                      <ZIndex>10</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <FontWeight>700</FontWeight>
                        <FontSize>11pt</FontSize>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <BackgroundColor>SteelBlue</BackgroundColor>
                        <Color>White</Color>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>ObjectTypeName</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox4">
                      <rd:DefaultName>textbox4</rd:DefaultName>
                      <ZIndex>9</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <FontWeight>700</FontWeight>
                        <FontSize>11pt</FontSize>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <BackgroundColor>SteelBlue</BackgroundColor>
                        <Color>White</Color>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>Filtered</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox5">
                      <rd:DefaultName>textbox5</rd:DefaultName>
                      <ZIndex>8</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <FontWeight>700</FontWeight>
                        <FontSize>11pt</FontSize>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <BackgroundColor>SteelBlue</BackgroundColor>
                        <Color>White</Color>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>ServerName</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox6">
                      <rd:DefaultName>textbox6</rd:DefaultName>
                      <ZIndex>7</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <FontWeight>700</FontWeight>
                        <FontSize>11pt</FontSize>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <BackgroundColor>SteelBlue</BackgroundColor>
                        <Color>White</Color>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>FontName</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
                <TableCell>
                  <ReportItems>
                    <Textbox Name="textbox7">
                      <rd:DefaultName>textbox7</rd:DefaultName>
                      <ZIndex>6</ZIndex>
                      <Style>
                        <BorderStyle>
                          <Default>Solid</Default>
                        </BorderStyle>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingBottom>2pt</PaddingBottom>
                        <FontFamily>Tahoma</FontFamily>
                        <FontWeight>700</FontWeight>
                        <FontSize>11pt</FontSize>
                        <BorderColor>
                          <Default>LightGrey</Default>
                        </BorderColor>
                        <BackgroundColor>SteelBlue</BackgroundColor>
                        <Color>White</Color>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                      </Style>
                      <CanGrow>true</CanGrow>
                      <Value>DatabaseName</Value>
                    </Textbox>
                  </ReportItems>
                </TableCell>
              </TableCells>
              <Height>0.22in</Height>
            </TableRow>
          </TableRows>
          <RepeatOnNewPage>true</RepeatOnNewPage>
        </Header>
        <TableColumns>
          <TableColumn>
            <Width>3in</Width>
          </TableColumn>
          <TableColumn>
            <Width>1.5in</Width>
          </TableColumn>
          <TableColumn>
            <Width>0.75in</Width>
          </TableColumn>
          <TableColumn>
            <Width>1.125in</Width>
          </TableColumn>
          <TableColumn>
            <Width>2in</Width>
          </TableColumn>
          <TableColumn>
            <Width>1.375in</Width>
          </TableColumn>
        </TableColumns>
      </Table>
    </ReportItems>
    <Height>0.79in</Height>
  </Body>
  <rd:ReportID>abb14e58-fd36-495a-89ff-b66f29ef287b</rd:ReportID>
  <LeftMargin>1in</LeftMargin>
  <DataSets>
    <DataSet Name="AllReportParameters">
      <Query>
        <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
        <CommandText>SELECT 1</CommandText>
        <DataSourceName>AllReportParameters</DataSourceName>
      </Query>
      <Fields>
        <Field Name="ObjectName">
          <rd:TypeName>System.String</rd:TypeName>
          <DataField>ObjectName</DataField>
        </Field>
        <Field Name="ObjectTypeName">
          <rd:TypeName>System.String</rd:TypeName>
          <DataField>ObjectTypeName</DataField>
        </Field>
        <Field Name="Filtered">
          <rd:TypeName>System.Boolean</rd:TypeName>
          <DataField>Filtered</DataField>
        </Field>
        <Field Name="ServerName">
          <rd:TypeName>System.String</rd:TypeName>
          <DataField>ServerName</DataField>
        </Field>
        <Field Name="FontName">
          <rd:TypeName>System.String</rd:TypeName>
          <DataField>FontName</DataField>
        </Field>
        <Field Name="DatabaseName">
          <rd:TypeName>System.String</rd:TypeName>
          <DataField>DatabaseName</DataField>
        </Field>
      </Fields>
    </DataSet>
  </DataSets>
  <Width>6.875in</Width>
  <InteractiveHeight>11in</InteractiveHeight>
  <Language>en-US</Language>
  <TopMargin>1in</TopMargin>
</Report>