<?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>
      <Tablix Name="Tablix1">
        <TablixBody>
          <TablixColumns>
            <TablixColumn>
              <Width>10.81666in</Width>
            </TablixColumn>
          </TablixColumns>
          <TablixRows>
            <TablixRow>
              <Height>0.55833in</Height>
              <TablixCells>
                <TablixCell>
                  <CellContents>
                    <Textbox Name="Textbox21">
                      <CanGrow>true</CanGrow>
                      <KeepTogether>true</KeepTogether>
                      <Paragraphs>
                        <Paragraph>
                          <TextRuns>
                            <TextRun>
                              <Value>="Table Definition for the " &amp; Parameters!SchemaName.Value &amp; "." &amp; Parameters!TableName.Value &amp; " in the " &amp; First(Fields!DatabaseName.Value, "DBName") &amp; " Database"</Value>
                              <Style>
                                <FontSize>18pt</FontSize>
                                <Color>White</Color>
                              </Style>
                            </TextRun>
                          </TextRuns>
                          <Style />
                        </Paragraph>
                      </Paragraphs>
                      <rd:DefaultName>Textbox21</rd:DefaultName>
                      <Style>
                        <Border>
                          <Color>LightGrey</Color>
                          <Style>Solid</Style>
                        </Border>
                        <BackgroundColor>DarkBlue</BackgroundColor>
                        <VerticalAlign>Middle</VerticalAlign>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                    </Textbox>
                  </CellContents>
                </TablixCell>
              </TablixCells>
            </TablixRow>
            <TablixRow>
              <Height>0.31667in</Height>
              <TablixCells>
                <TablixCell>
                  <CellContents>
                    <Textbox Name="Textbox16">
                      <CanGrow>true</CanGrow>
                      <KeepTogether>true</KeepTogether>
                      <Paragraphs>
                        <Paragraph>
                          <TextRuns>
                            <TextRun>
                              <Value>Back to Report</Value>
                              <ActionInfo>
                                <Actions>
                                  <Action>
                                    <Drillthrough>
                                      <ReportName>TableList</ReportName>
                                    </Drillthrough>
                                  </Action>
                                </Actions>
                              </ActionInfo>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value xml:space="preserve">   </Value>
                              <ActionInfo>
                                <Actions>
                                  <Action>
                                    <Drillthrough>
                                      <ReportName>AutoTuningCode</ReportName>
                                    </Drillthrough>
                                  </Action>
                                </Actions>
                              </ActionInfo>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value>|</Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>Gray</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value xml:space="preserve">  </Value>
                              <ActionInfo>
                                <Actions>
                                  <Action>
                                    <Drillthrough>
                                      <ReportName>AutoTuningCode</ReportName>
                                    </Drillthrough>
                                  </Action>
                                </Actions>
                              </ActionInfo>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value>Click Here to see the Query </Value>
                              <ActionInfo>
                                <Actions>
                                  <Action>
                                    <Drillthrough>
                                      <ReportName>TableScriptCode</ReportName>
                                    </Drillthrough>
                                  </Action>
                                </Actions>
                              </ActionInfo>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value xml:space="preserve">  </Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value>| </Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>Gray</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value xml:space="preserve">  </Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value>Go To Report Library</Value>
                              <ActionInfo>
                                <Actions>
                                  <Action>
                                    <Drillthrough>
                                      <ReportName>ReportLibrary</ReportName>
                                    </Drillthrough>
                                  </Action>
                                </Actions>
                              </ActionInfo>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value xml:space="preserve">   </Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value>|</Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>Gray</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value xml:space="preserve">   </Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>DarkBlue</Color>
                              </Style>
                            </TextRun>
                            <TextRun>
                              <Value>Go To Main Report </Value>
                              <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>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>=IIF(First(Fields!ProductMajorVersion.Value, "Version") = 10, "DarkBlue", IIF(First(Fields!EngineEdition.Value, "ServerProperty") = 5, "LightSteelBlue", "DarkBlue"))</Color>
                              </Style>
                            </TextRun>
                          </TextRuns>
                          <Style />
                        </Paragraph>
                      </Paragraphs>
                      <rd:DefaultName>Textbox16</rd:DefaultName>
                      <Style>
                        <Border>
                          <Color>LightGrey</Color>
                          <Style>Solid</Style>
                        </Border>
                        <BackgroundColor>LightSteelBlue</BackgroundColor>
                        <VerticalAlign>Middle</VerticalAlign>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                    </Textbox>
                  </CellContents>
                </TablixCell>
              </TablixCells>
            </TablixRow>
            <TablixRow>
              <Height>0.30833in</Height>
              <TablixCells>
                <TablixCell>
                  <CellContents>
                    <Textbox Name="Textbox1">
                      <CanGrow>true</CanGrow>
                      <KeepTogether>true</KeepTogether>
                      <Paragraphs>
                        <Paragraph>
                          <TextRuns>
                            <TextRun>
                              <Value>Script  (To Copy this Script Export this report to Word)</Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>White</Color>
                              </Style>
                            </TextRun>
                          </TextRuns>
                          <Style />
                        </Paragraph>
                      </Paragraphs>
                      <rd:DefaultName>Textbox1</rd:DefaultName>
                      <Style>
                        <Border>
                          <Color>LightGrey</Color>
                          <Style>Solid</Style>
                        </Border>
                        <BackgroundColor>DimGray</BackgroundColor>
                        <VerticalAlign>Middle</VerticalAlign>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                    </Textbox>
                  </CellContents>
                </TablixCell>
              </TablixCells>
            </TablixRow>
            <TablixRow>
              <Height>2.98666in</Height>
              <TablixCells>
                <TablixCell>
                  <CellContents>
                    <Textbox Name="TableDefinition">
                      <CanGrow>true</CanGrow>
                      <KeepTogether>true</KeepTogether>
                      <Paragraphs>
                        <Paragraph>
                          <TextRuns>
                            <TextRun>
                              <Value>=Fields!TableDefinition.Value</Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                              </Style>
                            </TextRun>
                          </TextRuns>
                          <Style>
                            <TextAlign>Left</TextAlign>
                          </Style>
                        </Paragraph>
                      </Paragraphs>
                      <rd:DefaultName>TableDefinition</rd:DefaultName>
                      <Style>
                        <Border>
                          <Color>LightGrey</Color>
                          <Style>Solid</Style>
                        </Border>
                        <BackgroundColor>=IIF(ROWNUMBER(NOTHING) MOD 2, "LIGHTBLUE", "SILVER")</BackgroundColor>
                        <VerticalAlign>Top</VerticalAlign>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                    </Textbox>
                  </CellContents>
                </TablixCell>
              </TablixCells>
            </TablixRow>
            <TablixRow>
              <Height>0.33333in</Height>
              <TablixCells>
                <TablixCell>
                  <CellContents>
                    <Textbox Name="Textbox11">
                      <CanGrow>true</CanGrow>
                      <KeepTogether>true</KeepTogether>
                      <Paragraphs>
                        <Paragraph>
                          <TextRuns>
                            <TextRun>
                              <Value>="End Of Report                  Completed By: " &amp; UCASE(User!UserID) &amp; " on " &amp; Globals!ExecutionTime</Value>
                              <Style>
                                <FontSize>14pt</FontSize>
                                <Color>White</Color>
                              </Style>
                            </TextRun>
                          </TextRuns>
                          <Style />
                        </Paragraph>
                      </Paragraphs>
                      <rd:DefaultName>Textbox11</rd:DefaultName>
                      <Style>
                        <Border>
                          <Color>LightGrey</Color>
                          <Style>Solid</Style>
                        </Border>
                        <BackgroundColor>DarkBlue</BackgroundColor>
                        <VerticalAlign>Middle</VerticalAlign>
                        <PaddingLeft>2pt</PaddingLeft>
                        <PaddingRight>2pt</PaddingRight>
                        <PaddingTop>2pt</PaddingTop>
                        <PaddingBottom>2pt</PaddingBottom>
                      </Style>
                    </Textbox>
                  </CellContents>
                </TablixCell>
              </TablixCells>
            </TablixRow>
          </TablixRows>
        </TablixBody>
        <TablixColumnHierarchy>
          <TablixMembers>
            <TablixMember />
          </TablixMembers>
        </TablixColumnHierarchy>
        <TablixRowHierarchy>
          <TablixMembers>
            <TablixMember>
              <KeepWithGroup>After</KeepWithGroup>
            </TablixMember>
            <TablixMember>
              <KeepWithGroup>After</KeepWithGroup>
            </TablixMember>
            <TablixMember>
              <KeepWithGroup>After</KeepWithGroup>
            </TablixMember>
            <TablixMember>
              <Group Name="Details" />
            </TablixMember>
            <TablixMember>
              <KeepWithGroup>Before</KeepWithGroup>
            </TablixMember>
          </TablixMembers>
        </TablixRowHierarchy>
        <DataSetName>TableDef</DataSetName>
        <Height>4.50332in</Height>
        <Width>10.81666in</Width>
        <Style>
          <Border>
            <Style>None</Style>
          </Border>
        </Style>
      </Tablix>
    </ReportItems>
    <Height>4.50332in</Height>
    <Style />
  </Body>
  <Width>10.81666in</Width>
  <Page>
    <PageHeight>300in</PageHeight>
    <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>4f052e85-c31e-410d-8fea-d175f19b9f9b</rd:DataSourceID>
    </DataSource>
  </DataSources>
  <DataSets>
    <DataSet Name="ServerName">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>Select @@servername AS 'ServerName'</CommandText>
      </Query>
      <Fields>
        <Field Name="ServerName">
          <DataField>ServerName</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
    <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="DBName">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <CommandText>SELECT DB_NAME() DatabaseName</CommandText>
      </Query>
      <Fields>
        <Field Name="DatabaseName">
          <DataField>DatabaseName</DataField>
          <rd:TypeName>System.String</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>
    <DataSet Name="TableDef">
      <Query>
        <DataSourceName>Local</DataSourceName>
        <QueryParameters>
          <QueryParameter Name="@SchemaName">
            <Value>=Parameters!SchemaName.Value</Value>
          </QueryParameter>
          <QueryParameter Name="@TableName">
            <Value>=Parameters!TableName.Value</Value>
          </QueryParameter>
        </QueryParameters>
        <CommandText>-- Source - https://stackoverflow.com/a/16797460
-- Posted by Devart, modified by community. See post 'Timeline' for change history
-- Retrieved 2026-02-12, License - CC BY-SA 4.0

DECLARE @table_name SYSNAME
SELECT @table_name = (@SchemaName) + '.' + (@TableName)

DECLARE 
      @object_name SYSNAME
    , @object_id INT

SELECT 
      @object_name = '[' + s.name + '].[' + o.name + ']'
    , @object_id = o.[object_id]
FROM sys.objects o WITH (NOWAIT)
JOIN sys.schemas s WITH (NOWAIT) ON o.[schema_id] = s.[schema_id]
WHERE s.name + '.' + o.name = @table_name
    AND o.[type] = 'U'
    AND o.is_ms_shipped = 0

DECLARE @SQL NVARCHAR(MAX) = ''

;WITH index_column AS 
(
    SELECT 
          ic.[object_id]
        , ic.index_id
        , ic.is_descending_key
        , ic.is_included_column
        , c.name
    FROM sys.index_columns ic WITH (NOWAIT)
    JOIN sys.columns c WITH (NOWAIT) ON ic.[object_id] = c.[object_id] AND ic.column_id = c.column_id
    WHERE ic.[object_id] = @object_id
),
fk_columns AS 
(
     SELECT 
          k.constraint_object_id
        , cname = c.name
        , rcname = rc.name
    FROM sys.foreign_key_columns k WITH (NOWAIT)
    JOIN sys.columns rc WITH (NOWAIT) ON rc.[object_id] = k.referenced_object_id AND rc.column_id = k.referenced_column_id 
    JOIN sys.columns c WITH (NOWAIT) ON c.[object_id] = k.parent_object_id AND c.column_id = k.parent_column_id
    WHERE k.parent_object_id = @object_id
)
SELECT @SQL = 'CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF((
    SELECT CHAR(9) + ', [' + c.name + '] ' + 
        CASE WHEN c.is_computed = 1
            THEN 'AS ' + cc.[definition] 
            ELSE UPPER(tp.name) + 
                CASE WHEN tp.name IN ('varchar', 'char', 'varbinary', 'binary', 'text')
                       THEN '(' + CASE WHEN c.max_length = -1 THEN 'MAX' ELSE CAST(c.max_length AS VARCHAR(5)) END + ')'
                     WHEN tp.name IN ('nvarchar', 'nchar', 'ntext')
                       THEN '(' + CASE WHEN c.max_length = -1 THEN 'MAX' ELSE CAST(c.max_length / 2 AS VARCHAR(5)) END + ')'
                     WHEN tp.name IN ('datetime2', 'time2', 'datetimeoffset') 
                       THEN '(' + CAST(c.scale AS VARCHAR(5)) + ')'
                    WHEN tp.name IN ('decimal', 'numeric')
                       THEN '(' + CAST(c.[precision] AS VARCHAR(5)) + ',' + CAST(c.scale AS VARCHAR(5)) + ')'
                    ELSE ''
                END +
                CASE WHEN c.collation_name IS NOT NULL THEN ' COLLATE ' + c.collation_name ELSE '' END +
                CASE WHEN c.is_nullable = 1 THEN ' NULL' ELSE ' NOT NULL' END +
                CASE WHEN dc.[definition] IS NOT NULL THEN ' DEFAULT' + dc.[definition] ELSE '' END + 
                CASE WHEN ic.is_identity = 1 THEN ' IDENTITY(' + CAST(ISNULL(ic.seed_value, '0') AS CHAR(1)) + ',' + CAST(ISNULL(ic.increment_value, '1') AS CHAR(1)) + ')' ELSE '' END 
        END + CHAR(13)
    FROM sys.columns c WITH (NOWAIT)
    JOIN sys.types tp WITH (NOWAIT) ON c.user_type_id = tp.user_type_id
    LEFT JOIN sys.computed_columns cc WITH (NOWAIT) ON c.[object_id] = cc.[object_id] AND c.column_id = cc.column_id
    LEFT JOIN sys.default_constraints dc WITH (NOWAIT) ON c.default_object_id != 0 AND c.[object_id] = dc.parent_object_id AND c.column_id = dc.parent_column_id
    LEFT JOIN sys.identity_columns ic WITH (NOWAIT) ON c.is_identity = 1 AND c.[object_id] = ic.[object_id] AND c.column_id = ic.column_id
    WHERE c.[object_id] = @object_id
    ORDER BY c.column_id
    FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, CHAR(9) + ' ')
    + ISNULL((SELECT CHAR(9) + ', CONSTRAINT [' + k.name + '] PRIMARY KEY (' + 
                    (SELECT STUFF((
                         SELECT ', [' + c.name + '] ' + CASE WHEN ic.is_descending_key = 1 THEN 'DESC' ELSE 'ASC' END
                         FROM sys.index_columns ic WITH (NOWAIT)
                         JOIN sys.columns c WITH (NOWAIT) ON c.[object_id] = ic.[object_id] AND c.column_id = ic.column_id
                         WHERE ic.is_included_column = 0
                             AND ic.[object_id] = k.parent_object_id 
                             AND ic.index_id = k.unique_index_id     
                         FOR XML PATH(N''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, ''))
            + ')' + CHAR(13)
            FROM sys.key_constraints k WITH (NOWAIT)
            WHERE k.parent_object_id = @object_id 
                AND k.[type] = 'PK'), '') + ')'  + CHAR(13)
    + ISNULL((SELECT (
        SELECT CHAR(13) +
             'ALTER TABLE ' + @object_name + ' WITH' 
            + CASE WHEN fk.is_not_trusted = 1 
                THEN ' NOCHECK' 
                ELSE ' CHECK' 
              END + 
              ' ADD CONSTRAINT [' + fk.name  + '] FOREIGN KEY(' 
              + STUFF((
                SELECT ', [' + k.cname + ']'
                FROM fk_columns k
                WHERE k.constraint_object_id = fk.[object_id]
                FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '')
               + ')' +
              ' REFERENCES [' + SCHEMA_NAME(ro.[schema_id]) + '].[' + ro.name + '] ('
              + STUFF((
                SELECT ', [' + k.rcname + ']'
                FROM fk_columns k
                WHERE k.constraint_object_id = fk.[object_id]
                FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '')
               + ')'
            + CASE 
                WHEN fk.delete_referential_action = 1 THEN ' ON DELETE CASCADE' 
                WHEN fk.delete_referential_action = 2 THEN ' ON DELETE SET NULL'
                WHEN fk.delete_referential_action = 3 THEN ' ON DELETE SET DEFAULT' 
                ELSE '' 
              END
            + CASE 
                WHEN fk.update_referential_action = 1 THEN ' ON UPDATE CASCADE'
                WHEN fk.update_referential_action = 2 THEN ' ON UPDATE SET NULL'
                WHEN fk.update_referential_action = 3 THEN ' ON UPDATE SET DEFAULT'  
                ELSE '' 
              END 
            + CHAR(13) + 'ALTER TABLE ' + @object_name + ' CHECK CONSTRAINT [' + fk.name  + ']' + CHAR(13)
        FROM sys.foreign_keys fk WITH (NOWAIT)
        JOIN sys.objects ro WITH (NOWAIT) ON ro.[object_id] = fk.referenced_object_id
        WHERE fk.parent_object_id = @object_id
        FOR XML PATH(N''), TYPE).value('.', 'NVARCHAR(MAX)')), '')
    + ISNULL(((SELECT
         CHAR(13) + 'CREATE' + CASE WHEN i.is_unique = 1 THEN ' UNIQUE' ELSE '' END 
                + ' NONCLUSTERED INDEX [' + i.name + '] ON ' + @object_name + ' (' +
                STUFF((
                SELECT ', [' + c.name + ']' + CASE WHEN c.is_descending_key = 1 THEN ' DESC' ELSE ' ASC' END
                FROM index_column c
                WHERE c.is_included_column = 0
                    AND c.index_id = i.index_id
                FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '') + ')'  
                + ISNULL(CHAR(13) + 'INCLUDE (' + 
                    STUFF((
                    SELECT ', [' + c.name + ']'
                    FROM index_column c
                    WHERE c.is_included_column = 1
                        AND c.index_id = i.index_id
                    FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '') + ')', '') + CASE WHEN ISNULL(i.filter_definition,'') = '' THEN '' ELSE ' WHERE ' + i.filter_definition END + CHAR(13)
        FROM sys.indexes i WITH (NOWAIT)
        WHERE i.[object_id] = @object_id
            AND i.is_primary_key = 0
            AND i.[type] = 2
        FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)')
    ), '')

Select @SQL AS 'TableDefinition';</CommandText>
      </Query>
      <Fields>
        <Field Name="TableDefinition">
          <DataField>TableDefinition</DataField>
          <rd:TypeName>System.String</rd:TypeName>
        </Field>
      </Fields>
    </DataSet>
  </DataSets>
  <ReportParameters>
    <ReportParameter Name="SchemaName">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <Prompt>ReportParameter1</Prompt>
      <Hidden>true</Hidden>
    </ReportParameter>
    <ReportParameter Name="TableName">
      <DataType>String</DataType>
      <Nullable>true</Nullable>
      <Prompt>TableName</Prompt>
      <Hidden>true</Hidden>
    </ReportParameter>
  </ReportParameters>
  <rd:ReportUnitType>Inch</rd:ReportUnitType>
  <rd:ReportID>5606433d-9ff9-4311-93ab-9c76ba05c3fd</rd:ReportID>
</Report>