How to convert dynamic SQL query to static query
<p>I have below dynamic script in SQL Server</p>

<pre><code>DECLARE @ArchiveDbName NVARCHAR(100)
SELECT TOP 1 @ArchiveDbName = ls.ArchiveDbName
FROM   LocalSetting ls

DECLARE @Query NVARCHAR(MAX) =
        'SELECT BusinessDocTypeID,
       RegDate,
       PersonID,
       ProductCode,
       bddv.Group4Code,
       NominalCode,
       UnitID,
       UnitName,
       ProductDescription,
       GrossWeight,
       NetWeight,
       Qty,
       SalePrice,
       UnitPrice,
       TotalNetWeight,
       TotalGrossWeight,
       TotalPrice,
       w.WHCode,
       @FinancialYear
FROM   ' + @ArchiveDbName +
        '.dbo.udfv_BusinessDocDetailView(@RunDate) AS bddv
       INNER JOIN dbo.udft_BusinessDoc(@RunDate) bd
            ON  bd.BusinessDocNo = bddv.BusinessDocNo
       INNER JOIN dbo.udft_WHDoc(@RunDate) w
            ON  w.WHDocNo = bd.WHDocNo
       WHERE  (bd.BusinessDocTypeID = @BusinessDocTypeID)
              AND bd.RegDate BETWEEN @FromShamsiDate AND @ToShamsiDate'
</code></pre>

<p>I'd like to get static form of that. is there any method to get this conversion?</p>

<p>Actually I want to use dynamic query in table valued function. But SQL Server doesn't let me that choice. </p>