Server must specify table in Query Manager

Dear All,
I am using below query to generate information related to GRPO but getting error
'microsoft sql server native client sql server must specify table to select from microsoft sql server native client Swei could not be prepared'
SELECT Distinct  T7.DOCNUM AS ' INVOICE No.',T7.DocDate as 'Invoice Date',T7.TaxDate as 'Document Date',T7.DocDueDate,'PO','DocDate',T7.CardCode as 'Vendor Code',  T7.CARDNAME as 'Vendor Name',
T7.NUMATCARD as 'Vendor Invoice No.', 
T7.SHIPTOCODE as 'Ship To Code',T6.ITEMCODE,T6.DSCRIPTION,T6.Width1, cast(T15.UserText as VarChar) as 'Item Remarks',
T6.QUANTITY,T6.WhsCode as 'Wh Name',T6.UnitMsr as 'UoM',T6.PRICE as 'Basic Price',T6.LineTotal as 'Basic Amount',
T10.[TransCat] as 'Purchase Type',T6.U_InvoiceNo 'Vendor Invoice No',T6.U_InvDate 'Vendor Invoice Date',
T7.Address As 'Bill To Address',T7.Address2 As 'Ship To Address',T7.U_CST,T7.U_VAT,T7.U_PAN,T12.[U_CreditRatPayer], T12.[U_CreditRatCheq], T12.[U_CreditRatPoints], T12.[U_DiscApp] ,
T10.State as 'Vendor State',
T15.[U_ItemType], T15.[U_Pattern], T15.[U_PurchaseType], T15.[U_Origin], T15.[U_ProductRange], T15.[U_NSD], T15.[U_Segment], T15.[U_SpeedRating],
T15.[U_Brand], T15.[U_Category], T15.[U_CompoType], T15.[U_OTHBCategory], T15.[U_WidthIN], T15.[U_WidthCM], T15.[U_RimWidthIN],
T15.[U_AspectRate], T15.[U_Plyrating], T15.[U_CountryMmanu], T15.[U_ProductType], T15.[U_Radiatyre], T15.[U_Loadindex], T15.[U_CategoryFTI], T15.[U_LoadindexFTI]
FROM        
                      dbo.PDN1 T6  inner join OPDN T7 ON T6.DocEntry = T7.DocEntry LEFT JOIN
                      dbo.OITM T15 ON T15.ItemCode = T6.ItemCode  LEFT JOIN
                      dbo.OSLP T8 on T7.SLPCode = T8.SlpCode    LEFT JOIN
                      dbo.OHEM T9 on T7.OwnerCode = T9.empID    LEFT JOIN
                      dbo.PDN12 T10 on T7.Docentry = T10.DocEntry LEFT JOIN
   dbo.OCRD T12 on T7.CardCode = T12.CardCode
  Where  T6.TargetType <> '19' and  T15.U_ItemType = 'Tyre' and  T7.DocDate >= '[%0]' and T7.DocDate <= '[%1]'
We tried to declare variable but error still appears.
Thanks
Deepak

Try This
/* select docdate from OPDN t1 */
DECLARE @d1 AS DATETIME
DECLARE @d2 AS DATETIME
SET @d1 =/* t1.docdate */ '[%0]'
SET @d2 =/* t1.docdate */ '[%1]'
SELECT DISTINCT T7.DOCNUM             AS ' INVOICE No.',
       T7.DocDate                     AS 'Invoice Date',
       T7.TaxDate                     AS 'Document Date',
       T7.DocDueDate,
       'PO',
       'DocDate',
       T7.CardCode                    AS 'Vendor Code',
       T7.CARDNAME                    AS 'Vendor Name',
       T7.NUMATCARD                   AS 'Vendor Invoice No.',
       T7.SHIPTOCODE                  AS 'Ship To Code',
       T6.ITEMCODE,
       T6.DSCRIPTION,
       T6.Width1,
       CAST(T15.UserText AS VARCHAR)  AS 'Item Remarks',
       T6.QUANTITY,
       T6.WhsCode                     AS 'Wh Name',
       T6.UnitMsr                     AS 'UoM',
       T6.PRICE                       AS 'Basic Price',
       T6.LineTotal                   AS 'Basic Amount',
       T10.[TransCat]                 AS 'Purchase Type',
       T6.U_InvoiceNo 'Vendor Invoice No',
       T6.U_InvDate 'Vendor Invoice Date',
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 10
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 BED,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 11
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 Cess,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 12
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 HeCess,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 5
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 ServiceTax,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 6
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 ServiceCess,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = -10
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 ServiceHeCess,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 1
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 VAT,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 7
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 Surcharge,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 8
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 EntryTax,
           SELECT DISTINCT ISNULL(SUM(PDN4.taxsum), 0)
           FROM   PDN4
           WHERE  PDN4.statype = 4
                  AND PDN4.docentry = T7.Docentry
                  AND PDN4.linenum = T6.Linenum
       )                                 CST,
       STR(
               SELECT (PDN3.[LineTotal] * T6.[LineTotal]) / (T7.[Doctotal] -T7.[TotalExpns] -T6.[VatSum])
               FROM   PDN3
               WHERE  PDN3.docentry = T7.Docentry
                      AND PDN3. ExpnsCode = '1'
           19,
           2
       )                              AS 'Freight',
       T7.[WTSum] * T6.[LineTotal] / (T7.[Doctotal] -T7.[TotalExpns] -T7.[VatSum] + T7.[WTSum]) AS
       'TDS',
       T7.DocTotal * T6.[LineTotal] / (T7.[Doctotal] -T7.[TotalExpns] -T7.[VatSum] + T7.[WTSum]) AS
       'DocTotal',
       T6.Freetxt                     AS ' Text',
       T8.[SlpName],
       (T9.[firstName] + ' ' + T9.[lastName]) AS 'Owner',
       T7.Address                     AS 'Bill To Address',
       T7.Address2                    AS 'Ship To Address',
       T7.U_CST,
       T7.U_VAT,
       T7.U_PAN,
       T12.[U_CreditRatPayer],
       T12.[U_CreditRatCheq],
       T12.[U_CreditRatPoints],
       T12.[U_DiscApp],
       T10.State                      AS 'Vendor State',
       T15.[U_ItemType],
       T15.[U_Pattern],
       T15.[U_PurchaseType],
       T15.[U_Origin],
       T15.[U_ProductRange],
       T15.[U_NSD],
       T15.[U_Segment],
       T15.[U_SpeedRating],
       T15.[U_Brand],
       T15.[U_Category],
       T15.[U_CompoType],
       T15.[U_OTHBCategory],
       T15.[U_WidthIN],
       T15.[U_WidthCM],
       T15.[U_RimWidthIN],
       T15.[U_AspectRate],
       T15.[U_Plyrating],
       T15.[U_CountryMmanu],
       T15.[U_ProductType],
       T15.[U_Radiatyre],
       T15.[U_Loadindex],
       T15.[U_CategoryFTI],
       T15.[U_LoadindexFTI]
FROM   dbo.PDN1 T6
       INNER JOIN OPDN T7
            ON  T6.DocEntry = T7.DocEntry
       LEFT JOIN dbo.OITM T15
            ON  T15.ItemCode = T6.ItemCode
       LEFT JOIN dbo.OSLP T8
            ON  T7.SLPCode = T8.SlpCode
       LEFT JOIN dbo.OHEM T9
            ON  T7.OwnerCode = T9.empID
       LEFT JOIN dbo.PDN12 T10
            ON  T7.Docentry = T10.DocEntry
       LEFT JOIN dbo.OCRD T12
            ON  T7.CardCode = T12.CardCode
WHERE  T6.TargetType <> '19'
       AND T15.U_ItemType = 'Tyre'
       AND T7.DocDate >= @d1
       AND T7.Docdate <= @d2

Similar Messages

  • Error in query: [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. '' (SWEI)

    Hi All
    below query giving me error in query generator but working well in Sql server.
    error: [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. '' (SWEI)
    Select
    T1.U_grp01 As 'BA',T3.DocDate As 'Posting Date',Month(T3.DocDate) As 'PostMonth',Year(T3.DocDate) As 'PostYear',
    'AR Invoice' As 'Type',T3.DocNum As 'Doc No',T3.CardCode As 'Cust. Code',T3.CardName As 'Cust. Name',T5.SlpName As 'Sale Emp. Name',
    T4.IndustryC As 'Channel Type',T6.CityB As 'BillToCity',T7.Name As 'BillToState',T6.CityS As 'ShipToCity',T8.Name As 'ShipToState',
    T4.U_Une_Zone As 'Zone',
    T2.ItmsGrpNam As 'L1',T0.LineNum As 'Row No',T0.ItemCode As 'ItemCode',T0.Dscription As 'Item Name',t0.whscode,
    T0.Quantity As 'Quantity',T0.StockPrice As 'COGS Price',IsNull(Sum(T0.Quantity * T0.StockPrice),0) As 'COGS Value',T0.VatSum As 'Tax Amount',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.PriceBefDi Else (T0.PriceBefDi * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.INMPrice Else (T0.INMPrice * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then Sum(T0.Quantity * T0.INMPrice) Else Sum(T0.Quantity * T0.INMPrice * T0.Rate) End) Else T0.LineTotal End) ,0) As 'Sales Value',t9.linetotal as 'Freight',
    T3.DocType As 'DocType',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = -90
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'BED',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = -60
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'Cess',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = 9
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'HeCess',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE (INV4.StaType = 1 or inv4.staType = 8)
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'VAT',
    (SELECT DISTINCT ISNULL (SUM(INV4.TaxSum),0)
    FROM INV4
    WHERE INV4.StaType = 8
    AND INV4.DocEntry = T3.DocEntry
    AND INV4.LineNum = T0.LineNum) AS 'CST'
    From INV1 T0
    Left Join OITM T1 On T1.ItemCode=T0.ItemCode
    Left Join OITB T2 On T2.ItmsGrpCod=T1.ItmsGrpCod
    Left Join OINV T3 On T3.DocEntry=T0.DocEntry
    Left Join OCRD T4 On T4.CardCode=T3.CardCode
    Left Join OSLP T5 On T5.SlpCode=T4.SlpCode
    Left Join INV12 T6 On T6.DocEntry=T0.DocEntry
    Left Join OCST T7 On T7.Code=T6.StateB and T7.Country='IN'
    Left Join OCST T8 On T8.Code=T6.StateS and T8.Country='IN'
    left join inv3 t9 on t9.docentry = t3.docentry
    WHERE T3.[DocDate] >= [%0] and T3.[DocDate] <= [%1] and t3.U_UNE_GCAT = '2'
    Group By T1.U_grp01,T3.DocEntry,T3.DocNum,T3.DocDate,T0.LineNum,T3.CardCode,T3.CardName,T5.SlpName,T4.IndustryC,T4.U_Une_Zone,
    T6.CityB,T7.Name,T6.CityS,T8.Name,T0.VatSum,T0.Currency,T0.Rate,T3.DocType,T0.Price,T0.LineTotal,
    T2.ItmsGrpNam,T0.ItemCode,T0.Dscription,T0.StockPrice,T0.INMPrice,T0.PriceBefDi,T0.Quantity,t9.linetotal,t0.WhsCode
    Union All
    Select
    T1.U_grp01 As 'BA',T3.DocDate As 'Posting Date',Month(T3.DocDate) As 'PostMonth',Year(T3.DocDate) As 'PostYear',
    'AR Invoice' As 'Type',T3.DocNum As 'Doc No',T3.CardCode As 'Cust. Code',T3.CardName As 'Cust. Name',T5.SlpName As 'Sale Emp. Name',
    T4.IndustryC As 'Channel Type',T6.CityB As 'BillToCity',T7.Name As 'BillToState',T6.CityS As 'ShipToCity',T8.Name As 'ShipToState',
    T4.U_Une_Zone As 'Zone',
    T2.ItmsGrpNam As 'L1',T0.LineNum As 'Row No',T0.ItemCode As 'ItemCode',T0.Dscription As 'Item Name',t0.whscode,
    T0.Quantity As 'Quantity',T0.StockPrice As 'COGS Price',IsNull(Sum(T0.Quantity * T0.StockPrice),0) As 'COGS Value',T0.VatSum As 'Tax Amount',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.PriceBefDi Else (T0.PriceBefDi * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then T0.INMPrice Else (T0.INMPrice * T0.Rate) End) Else T0.Price End) ,0) As 'Sales Price',
    IsNull((Case When T3.DocType='I' Then (Case  When T0.Currency = 'INR' Then Sum(T0.Quantity * T0.INMPrice) Else Sum(T0.Quantity * T0.INMPrice * T0.Rate) End) Else T0.LineTotal End) ,0) As 'Sales Value',t9.linetotal as 'Freight',
    T3.DocType As 'DocType',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = -90
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'BED',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = -60
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'Cess',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = 9
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'HeCess',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE (rin4.StaType = 1 or rin4.staType = 8)
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'VAT',
    (SELECT DISTINCT ISNULL (SUM(rin4.TaxSum),0)
    FROM rin4
    WHERE rin4.StaType = 8
    AND rin4.DocEntry = T3.DocEntry
    AND rin4.LineNum = T0.LineNum) AS 'CST'
    From rin1 T0
    Left Join OITM T1 On T1.ItemCode=T0.ItemCode
    Left Join OITB T2 On T2.ItmsGrpCod=T1.ItmsGrpCod
    Left Join Orin T3 On T3.DocEntry=T0.DocEntry
    Left Join OCRD T4 On T4.CardCode=T3.CardCode
    Left Join OSLP T5 On T5.SlpCode=T4.SlpCode
    Left Join rin12 T6 On T6.DocEntry=T0.DocEntry
    Left Join OCST T7 On T7.Code=T6.StateB and T7.Country='IN'
    Left Join OCST T8 On T8.Code=T6.StateS and T8.Country='IN'
    left join rin3 t9 on t9.docentry = t3.docentry
    WHERE T3.[DocDate] >= [%0] and T3.[DocDate] <= [%1] and t3.U_UNE_GCAT = '2'
    Group By T1.U_grp01,T3.DocEntry,T3.DocNum,T3.DocDate,T0.LineNum,T3.CardCode,T3.CardName,T5.SlpName,T4.IndustryC,T4.U_Une_Zone,
    T6.CityB,T7.Name,T6.CityS,T8.Name,T0.VatSum,T0.Currency,T0.Rate,T3.DocType,T0.Price,T0.LineTotal,
    T2.ItmsGrpNam,T0.ItemCode,T0.Dscription,T0.StockPrice,T0.INMPrice,T0.PriceBefDi,T0.Quantity,t9.linetotal,t0.WhsCode
    Thanks in Advance

    Hi deepak..
    try this
    /* SELECT FROM OSRT P1 */
    DECLARE @FROM AS DATE
    /* WHERE */
    SET @FROM = /* P1.FromDate */ '[%1]'
    /* SELECT FROM OSRT P2 */
    DECLARE @TO AS DATE
    /* WHERE */
    SET @TO = /* P2.ToDate */ '[%2]';
    SELECT T1.U_grp01 AS 'BA',
           T3.DocDate AS 'Posting Date',
           MONTH(T3.DocDate) AS 'PostMonth',
           YEAR(T3.DocDate) AS 'PostYear',
           'AR Invoice' AS 'Type',
           T3.DocNum AS 'Doc No',
           T3.CardCode AS 'Cust. Code',
           T3.CardName AS 'Cust. Name',
           T5.SlpName AS 'Sale Emp. Name',
           T4.IndustryC AS 'Channel Type',
           T6.CityB AS 'BillToCity',
           T7.Name AS 'BillToState',
           T6.CityS AS 'ShipToCity',
           T8.Name AS 'ShipToState',
           T4.U_Une_Zone AS 'Zone',
           T2.ItmsGrpNam AS 'L1',
           T0.LineNum AS 'Row No',
           T0.ItemCode AS 'ItemCode',
           T0.Dscription AS 'Item Name',
           t0.whscode,
           T0.Quantity AS 'Quantity',
           T0.StockPrice AS 'COGS Price',
           ISNULL(SUM(T0.Quantity * T0.StockPrice), 0) AS 'COGS Value',
           T0.VatSum AS 'Tax Amount',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.PriceBefDi
                                      ELSE (T0.PriceBefDi * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.INMPrice
                                      ELSE (T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN SUM(T0.Quantity * T0.INMPrice)
                                      ELSE SUM(T0.Quantity * T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.LineTotal
                   END
               0
           ) AS 'Sales Value',
           t9.linetotal AS 'Freight',
           T3.DocType AS 'DocType',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = -90
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'BED',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = -60
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'Cess',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = 9
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'HeCess',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  (INV4.StaType = 1 OR inv4.staType = 8)
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'VAT',
               SELECT DISTINCT ISNULL(SUM(INV4.TaxSum), 0)
               FROM   INV4
               WHERE  INV4.StaType = 8
                      AND INV4.DocEntry = T3.DocEntry
                      AND INV4.LineNum = T0.LineNum
           ) AS 'CST'
    FROM   INV1 T0
           LEFT JOIN OITM T1
                ON  T1.ItemCode = T0.ItemCode
           LEFT JOIN OITB T2
                ON  T2.ItmsGrpCod = T1.ItmsGrpCod
           LEFT JOIN OINV T3
                ON  T3.DocEntry = T0.DocEntry
           LEFT JOIN OCRD T4
                ON  T4.CardCode = T3.CardCode
           LEFT JOIN OSLP T5
                ON  T5.SlpCode = T4.SlpCode
           LEFT JOIN INV12 T6
                ON  T6.DocEntry = T0.DocEntry
           LEFT JOIN OCST T7
                ON  T7.Code = T6.StateB
                AND T7.Country = 'IN'
           LEFT JOIN OCST T8
                ON  T8.Code = T6.StateS
                AND T8.Country = 'IN'
           LEFT JOIN inv3 t9
                ON  t9.docentry = t3.docentry
    WHERE  T3.[DocDate] >= @FROM
           AND T3.[DocDate] <= @TO
           AND t3.U_UNE_GCAT = '2'
    GROUP BY
           T1.U_grp01,
           T3.DocEntry,
           T3.DocNum,
           T3.DocDate,
           T0.LineNum,
           T3.CardCode,
           T3.CardName,
           T5.SlpName,
           T4.IndustryC,
           T4.U_Une_Zone,
           T6.CityB,
           T7.Name,
           T6.CityS,
           T8.Name,
           T0.VatSum,
           T0.Currency,
           T0.Rate,
           T3.DocType,
           T0.Price,
           T0.LineTotal,
           T2.ItmsGrpNam,
           T0.ItemCode,
           T0.Dscription,
           T0.StockPrice,
           T0.INMPrice,
           T0.PriceBefDi,
           T0.Quantity,
           t9.linetotal,
           t0.WhsCode
    UNION ALL
    SELECT T1.U_grp01 AS 'BA',
           T3.DocDate AS 'Posting Date',
           MONTH(T3.DocDate) AS 'PostMonth',
           YEAR(T3.DocDate) AS 'PostYear',
           'AR Invoice' AS 'Type',
           T3.DocNum AS 'Doc No',
           T3.CardCode AS 'Cust. Code',
           T3.CardName AS 'Cust. Name',
           T5.SlpName AS 'Sale Emp. Name',
           T4.IndustryC AS 'Channel Type',
           T6.CityB AS 'BillToCity',
           T7.Name AS 'BillToState',
           T6.CityS AS 'ShipToCity',
           T8.Name AS 'ShipToState',
           T4.U_Une_Zone AS 'Zone',
           T2.ItmsGrpNam AS 'L1',
           T0.LineNum AS 'Row No',
           T0.ItemCode AS 'ItemCode',
           T0.Dscription AS 'Item Name',
           t0.whscode,
           T0.Quantity AS 'Quantity',
           T0.StockPrice AS 'COGS Price',
           ISNULL(SUM(T0.Quantity * T0.StockPrice), 0) AS 'COGS Value',
           T0.VatSum AS 'Tax Amount',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.PriceBefDi
                                      ELSE (T0.PriceBefDi * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN T0.INMPrice
                                      ELSE (T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.Price
                   END
               0
           ) AS 'Sales Price',
           ISNULL(
                   CASE
                        WHEN T3.DocType = 'I' THEN (
                                 CASE
                                      WHEN T0.Currency = 'INR' THEN SUM(T0.Quantity * T0.INMPrice)
                                      ELSE SUM(T0.Quantity * T0.INMPrice * T0.Rate)
                                 END
                        ELSE T0.LineTotal
                   END
               0
           ) AS 'Sales Value',
           t9.linetotal AS 'Freight',
           T3.DocType AS 'DocType',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = -90
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'BED',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = -60
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'Cess',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = 9
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'HeCess',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  (rin4.StaType = 1 OR rin4.staType = 8)
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'VAT',
               SELECT DISTINCT ISNULL(SUM(rin4.TaxSum), 0)
               FROM   rin4
               WHERE  rin4.StaType = 8
                      AND rin4.DocEntry = T3.DocEntry
                      AND rin4.LineNum = T0.LineNum
           ) AS 'CST'
    FROM   rin1 T0
           LEFT JOIN OITM T1
                ON  T1.ItemCode = T0.ItemCode
           LEFT JOIN OITB T2
                ON  T2.ItmsGrpCod = T1.ItmsGrpCod
           LEFT JOIN [dbo].[Orin] T3
                ON  T3.DocEntry = T0.DocEntry
           LEFT JOIN OCRD T4
                ON  T4.CardCode = T3.CardCode
           LEFT JOIN OSLP T5
                ON  T5.SlpCode = T4.SlpCode
           LEFT JOIN rin12 T6
                ON  T6.DocEntry = T0.DocEntry
           LEFT JOIN OCST T7
                ON  T7.Code = T6.StateB
                AND T7.Country = 'IN'
           LEFT JOIN OCST T8
                ON  T8.Code = T6.StateS
                AND T8.Country = 'IN'
           LEFT JOIN rin3 t9
                ON  t9.docentry = t3.docentry
    WHERE  T3.[DocDate] >= @FROM
           AND T3.[DocDate] <= @TO
           AND t3.U_UNE_GCAT = '2'
    GROUP BY
           T1.U_grp01,
           T3.DocEntry,
           T3.DocNum,
           T3.DocDate,
           T0.LineNum,
           T3.CardCode,
           T3.CardName,
           T5.SlpName,
           T4.IndustryC,
           T4.U_Une_Zone,
           T6.CityB,
           T7.Name,
           T6.CityS,
           T8.Name,
           T0.VatSum,
           T0.Currency,
           T0.Rate,
           T3.DocType,
           T0.Price,
           T0.LineTotal,
           T2.ItmsGrpNam,
           T0.ItemCode,
           T0.Dscription,
           T0.StockPrice,
           T0.INMPrice,
           T0.PriceBefDi,
           T0.Quantity,
           t9.linetotal,
           t0.WhsCode
    rgds
    Kennedy

  • Error while executing SQL query -' Must Specify Table to select from'

    Hi all,
    While executing query using query generator
    it shows error message
    [Microsoft][SQL Native Client][SQL Server]Must specify table to select from.
    2). [Microsoft][SQL Nativ
    SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
    FROM dbo.[OPCH] T0  INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
    WHERE T0.DocDate >='[%0]' AND  T0.DocDate <='[%1]' AND T0.DocType = 'I'
    GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
    It's executing fine in MS SQL Server Studio Management.
    Please give y'r ideas to solve the problem.
    Jeyakanthan

    try this, it works fine in my B1:
    SELECT T1.ItemCode, T1.Dscription AS 'Item Description', T1.Quantity, T1.Price, T1.LineTotal,
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-90 AND T1.LineNum=T2.LineNum) as 'BEDAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=-60 AND T1.LineNum=T2.LineNum) as 'ECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=7 AND T1.LineNum=T2.LineNum) as 'HECSAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=1 AND T1.LineNum=T2.LineNum) as 'VATAmt',
    (Select SUM(T2.TaxSum) From PCH4 T2 Where T0.DocEntry=T2.DocEntry AND T2.staType=4 AND T1.LineNum=T2.LineNum) as 'CSTAmt'
    FROM dbo.OPCH T0  INNER JOIN PCH1 T1 ON T0.DocEntry = T1.DocEntry INNER JOIN PCH4 T2 ON T2.DocEntry=T0.DocEntry
    WHERE T0.DocDate >='[%0]' AND  T0.DocDate <='[%1]' AND T0.DocType = 'I'
    GROUP BY T1.ItemCode,T1.Dscription,T1.Quantity, T1.Price, T1.LineTotal,T0.DocEntry,T1.DocEntry,T1.LineNum,T2.LineNum
    B1 don't like brackets!
    Regards

  • Must specify table to select from

    hi everybody
    i think  sometime we received this error message:
    1).[Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to selet from. 2).[Microsoft][SQL Server Native Client 10.0][SQL Server]Statment 'Contrato de Servicio' (OCTR)(s) could not be prepared.
    when i'm working in SQL Server the qry run fine, but when i run in SAP, i receive the error before mentioned.
    the Qry is this:
    DECLARE @FechaIni datetime,     
            @FechaFin datetime,
            @FechaAct datetime
    SET @FechaAct = GETDATE()
    SET @FechaIni = [%0]
    SET @FechaFin = [%1]
    CREATE TABLE #Libo_Mayor_CS (
                                    CodCta nvarchar(max),
                                    CtasPadre nvarchar(max),
                                    NbreCta nvarchar(max),
                                    Nivel numeric(1),
                                    Rubro numeric(1),
                                    SldoInicial numeric(19,6),
                                    Debe numeric(19,6),
                                    Haber numeric(19,6),
                                    SldoFinal numeric(19,6)
    INSERT INTO #Libo_Mayor_CS
    SELECT T0.[AcctCode],
           CASE
               WHEN T0.[Levels] <=3 THEN T0.[AcctName]
               ELSE  ''
           END,
           T0.[Levels],
           T0.[GroupMask],
           0.00,
           0.00,
           0.00,
           0.00                                          
    FROM OACT T0
         LEFT JOIN JDT1 T1 ON T0.[AcctCode] = T1.[Account]
    WHERE T0.[Levels] BETWEEN 1 AND 3 AND
          T0.[GroupMask]   BETWEEN 1 AND 5
    GROUP BY T0.[AcctCode],
             T1.[Account],
             T0.[Levels],
             T0.[AcctName],
             T0.[GroupMask]
    INSERT INTO #Libo_Mayor_CS
    SELECT T0.[AcctCode],
           CASE
               WHEN T0.[Levels] >3 THEN T0.[AcctName]
               ELSE  ''
           END,
           T0.[Levels],
           T0.[GroupMask],
           CASE
               WHEN T0.GroupMask  = 1 THEN (select t11.[CurrTotal]+sum(t10.[Debit])-sum(t10.[credit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 2 THEN (select t11.[CurrTotal]-sum(t10.[Credit])-sum(t10.[Debit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 4 THEN (select t11.[CurrTotal]+sum(t10.[Debit])-sum(t10.[credit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
               WHEN T0.GroupMask  = 5 THEN (select t11.[CurrTotal]-sum(t10.[Credit])-sum(t10.[Debit]) from oact t11 left join jdt1 t10 on t11.[AcctCode] = t10.[Account] where t10.[RefDate] between @FechaIni and @FechaAct and t11.[AcctCode] = T0.[AcctCode] group by t11.[CurrTotal])
           END,
           SUM(T1.[Credit]),
           SUM(T1.[Debit]),
           0.00                                          
    FROM OACT T0
         LEFT JOIN JDT1 T1 ON T0.[AcctCode]  = T1.[Account]
    WHERE T0.[Levels] > 3 AND
          T0.[GroupMask]  BETWEEN 1 AND 5 AND
         (T1.[RefDate] between @FechaIni AND @FechaFin)
    GROUP BY T0.[AcctCode],
             T1.[Account],
             T0.[Levels],
             T0.[AcctName],
             T0.[GroupMask]
    SELECT A.[CodCta] 'Codigo de Cuenta',
           A.[CtasPadre] 'Cuentas Padre',
           A.[NbreCta] 'Nombre de Cuenta',
           A.[Nivel] 'Nivel',
           A.[Rubro] 'Rubro',
           A.[SldoInicial] 'Saldo Inicial',
           A.[Debe] 'Debito',
           A.[Haber] 'Credito',
           CASE
               WHEN A.[Rubro] = 1 THEN (A.[SldoInicial] + A.[Debe] - A.[Haber])
               WHEN A.[Rubro] = 2 THEN (A.[SldoInicial] + A.[Haber] - A.[Debe])
               WHEN A.[Rubro] = 4 THEN (A.[SldoInicial] + A.[Debe] - A.[Haber])
               WHEN A.[Rubro] = 5 THEN (A.[SldoInicial] + A.[Haber] - A.[Debe])
               ELSE 0
           END 'Saldo'
    FROM #Libo_Mayor_CS A
    ORDER BY A.[CodCta]
    DROP TABLE #Libo_Mayor_CS
    if  assign the value to variables directly the Qry run in SAP but when i change the comodin to capture the variables value of SAP , there is when the problem ocurre
    DECLARE @FechaIni datetime,     
                    @FechaFin datetime,
                    @FechaAct datetime
    SET @FechaAct = GETDATE()
    SET @FechaIni =  '20110601'
    SET @FechaFin = '20110630'
    i wait for your recomendations
    Edited by: AlexMeza on Jun 15, 2011 1:29 AM

    Hi all !
    Sorry because i dont know where post new.
    My issue, when i using querry manager to call store in Database like this
    Declare @Fromdate Datetime
    Declare @Todate Datetime
    Declare @AcctCode nvarchar (20)
    set @Fromdate = (select distinct (T1.RefDate) from OJDT T1 where T1.RefDate = '[%0]')
    set @Todate = (select distinct (T2.RefDate) from OJDT T2 where T2.RefDate = '[%1]')
    set @AcctCode = (select distinct(T3.AcctCode) from OACT as T3 where T3.AcctCode ='[%2]' )
    exec [USP_RPT_FI_GENERALLEDGER] @Fromdate, @Todate, @AcctCode
    and i run this querry
    this error:
    1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Must specify table to select from. 2). [Microsoft][SQL Server Native Client 10.0][SQL Server]Statement 'Service Contracts' (OCTR) (s) could not be prepared.
    Please help me fix this issue
    Regards!
    John Le.

  • MUST SPECIFY TABLE TO SELECT FROM ,2 RECEIVED ALERTS COULD NOT BE PREPARED

    **Dear All, I get this Error"MUST SPECIFY TABLE TO SELECT FROM ,2 RECEIVED ALERTS COULD NOT BE PREPARED"** Please help me solve this
    SELECT T1.AcctCode, T1.AcctName FROM OACT T1  WHERE (T1.AcctCode ='ACACBB0001' OR  T1.AcctCode ='ACACBBBP01' OR  T1.AcctCode ='ACACBBBP02' OR  T1.AcctCode ='ACACBBBP03' OR  T1.AcctCode ='ACACBBBP04' OR  T1.AcctCode ='LLFSLCC001' OR  T1.AcctCode ='LLFSLCC002' OR  T1.AcctCode ='LLFSLTL001' OR  T1.AcctCode ='LLFULFO001')
    AND  T1.AcctCode   NOT IN (SELECT  T0.Account  FROM JDT1 T0 WHERE   T0.REFDATE<='[%0]' AND (T0.Account ='ACACBB0001' OR T0.Account ='ACACBBBP01' OR T0.Account ='ACACBBBP02' OR T0.Account ='ACACBBBP03' OR T0.Account ='ACACBBBP04' OR T0.Account ='LLFSLCC001' OR T0.Account ='LLFSLCC002' OR T0.Account ='LLFSLTL001' OR T0.Account ='LLFULFO001' ) )
    Regrds
    MD Zubair

    change the query as
    declare @date datetime
    SELECT @date =  T0.refdate FROM JDT1 T0 WHERE T0.REFDATE ='[%0]'
    SELECT T1.AcctCode, T1.AcctName FROM OACT T1 WHERE (T1.AcctCode ='ACACBB0001' OR T1.AcctCode ='ACACBBBP01' OR T1.AcctCode ='ACACBBBP02' OR T1.AcctCode ='ACACBBBP03' OR T1.AcctCode ='ACACBBBP04' OR T1.AcctCode ='LLFSLCC001' OR T1.AcctCode ='LLFSLCC002' OR T1.AcctCode ='LLFSLTL001' OR T1.AcctCode ='LLFULFO001')
    AND T1.AcctCode NOT IN (SELECT T0.Account FROM JDT1 T0 WHERE T0.REFDATE<=@date AND (T0.Account ='ACACBB0001' OR T0.Account ='ACACBBBP01' OR T0.Account ='ACACBBBP02' OR T0.Account ='ACACBBBP03' OR T0.Account ='ACACBBBP04' OR T0.Account ='LLFSLCC001' OR T0.Account ='LLFSLCC002' OR T0.Account ='LLFSLTL001' OR T0.Account ='LLFULFO001' ) )

  • Selection Problem in SAP B1 Query Manager

    Experts,
    select T0.DocNum 'AR Invoice Number',
    T0.DocDate 'AR Invoice Date',
    T0.CardCode,
    T0.CardName,
    T0.NumAtCard 'Vendor Ref No',
    (select sum (T1.Quantity * T1.Price) from INV1 T1 where T1.DocEntry = T0.DocEntry) 'Base Amount',
    ISNULL ((select sum (T3.TaxSum) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='1'), 0)'VAT Amount',
    ISNULL ((select MAX (T3.TaxRate) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='1'), 0)'VAT %',
    ISNULL ((select sum (T3.TaxSum) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='4'), 0)'CST Amount',
    ISNULL ((select MAX (T3.TaxRate) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='4'), 0)'CST %',
    ISNULL ((select sum (T3.TaxSum) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='5'), 0)'Service Amount',
    ISNULL ((select MAX (T3.TaxRate) from INV4 T3 where T3.DocEntry = T0.DocEntry and T3.StaType='5'), 0)'Service %',
    T0.TotalExpns 'Freight Amount',
    T0.WTSum 'TDS Amount',
    T0.DocTotal 'Document Total'
    from OINV T0
    where T0.DocDate >= '[%0]'
    and T0.DocDate <= '[%1]'
    When I run this query in SBO query maanger, it gives error for the selection criterias.
    1). [Microsoft][SQL Native Client][SQL Server]Must specify table to select from. 2). [Microsoft][SQL Native Client][SQL Server]Statement 'User-Defined Values' (CSHS) (s) could not be prepared.
    Please hlp

    Hi Rahul,
    I have just added credit memo with the query as per need, but same problem it shows!
    SELECT T0.[DocNum] 'AR Invoice #',
    T0.[DocDate] 'Date',
    T0.CardName 'Customer Name',
    T0.NumAtCard As 'Customer Ref',
    T0.[CardName], 
    Sum(T1.LineTotal) 'Base Amount',
    T0.[DocTotal] As 'Total Value',
    (isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxSum else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) 'VAT_Amt',
    (isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxRate else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'VAT%',
    (isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxSum else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'CST_Amt',
    (isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxRate else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'CST%',
    (isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxSum else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'Service_Amt',
    (isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxRate else 0 end))
    FROM INV4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'Service%',
    T0.TotalExpns 'Freight Amount',
    T0.WTSum 'TDS Amount',
    T0.DocTotal 'Grand Total'
    FROM OINV T0  INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T0.DocDate>='[%0]' And T0.DocDate<='[%1]'
    Group By T0.[DocNum], T0.[DocDate], T0.NumAtCard, T0.[CardName], T0.[DocTotal] , T0.TotalExpns, T0.WTSum, T0.DocEntry,
    T0.WTSum,
    T0.TotalExpns
    Union All
    SELECT T0.[DocNum] 'AR Invoice #',
    T0.[DocDate] 'Date',
    T0.CardName 'Customer Name',
    T0.NumAtCard As 'Customer Ref',
    T0.[CardName], 
    -Sum(T1.LineTotal) 'Base Amount',
    -T0.[DocTotal] As 'Total Value',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxSum else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) 'VAT_Amt',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =1 then T4.TaxRate else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'VAT%',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxSum else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'CST_Amt',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =4 then T4.TaxRate else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'CST%',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxSum else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry ),0)) As 'Service_Amt',
    -(isnull((SELECT SUM((case when upper(t4.STAType) =5 then T4.TaxRate else 0 end))
    FROM RIN4 T4 WHERE T4.DocEntry=T0.DocEntry And T4.LineNum=0),0)) As 'Service%',
    -T0.TotalExpns 'Freight Amount',
    -T0.WTSum 'TDS Amount',
    -T0.DocTotal 'Grand Total'
    FROM ORIN T0  INNER JOIN RIN1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T0.DocDate>='[%0]' And T0.DocDate<='[%1]'
    Group By T0.[DocNum], T0.[DocDate], T0.NumAtCard, T0.[CardName], T0.[DocTotal] , T0.TotalExpns, T0.WTSum, T0.DocEntry,
    T0.WTSum,
    T0.TotalExpns
    Plz hlp

  • Passing Parms to Query Manager

    I have seen several questions and answers in the forum on this but would like to confirm what I perceive to be the limitations.
    The following code works and allows the entry of two parms:
    set @parm_rep = (SELECT t0.slpcode FROM oinv t0 where t0.slpcode = '[%0]' )
    set @parm_date = (SELECT t0.docduedate FROM oinv t0 where t0.docduedate = '[%1]' )
    Requirement 1: table alias must be the same. That is, the above works but the following does not
    set @parm_rep = (SELECT t0.slpcode FROM oinv t0 where t0.slpcode = '[%0]' )
    set @parm_date = (SELECT t1.docduedate FROM oinv t1 where t1.docduedate = '[%1]' )
    Requirement 2: tables must be the same. That is, the following does not work
    set @parm_rep = (SELECT t1.slpcode FROM oslp t1 where t1.slpname = '[%0]' )
    set @parm_date = (SELECT t1.docduedate FROM oinv t1 where t1.docduedate = '[%1]' )
    Requirement 2, in particular, prevents me from allowing the User to select from a list of Salesrep names and Invoice dates because the Salesrep name is not carried on the Invoice, only the code.
    In general, I can not have parameters set from different tables for use later in the query and am restricted to only paremeters that are represented within one specific table. I then created my own table which contained the combination of fields I wanted to select from. While I could select from that table in Query Manager, I was unable to set a parm from that table.

    You can use more table for getting parameter values. And you donu2019t need to use only existing values from the tables. You can close the select inside a comment and use the manually entered parameter values.
    Like this:
    declare @n char(20)
    declare @i char(20)
    /*SELECT T0.[DocNum], T1.[ItemCode]
    FROM ORDR T0  INNER JOIN RDR1 T1 ON T0.DocEntry = T1.DocEntry
    WHERE T0.[DocNum] ='[%1]' and  T1.[ItemCode] ='[%0]'*/
    set @n='[%1]'
    set @i='[%0]'
    select @n,@i

  • RecordSet message: Must Declare Table Variable

    Hi
    I am trying to read a table using a RecordSet
    Private oRecordSet As SAPbobsCOM.Recordset
    Dim oSqlString As String = "Select U_tno, U_cpro from @MX_N301"
    Try
            oRecordSet.DoQuery(oSqlString)
    Catch ex As Exception
    And ex receives the next message:[Microsoft][ODBC SQL Server Driver][SQL Server]Must declate table variable "@MX_N301"
    Can anybody tell me why I receive this message and what else do I have to do?
    Thanks a lot

    Hi Alberto,
    for tables with  @ you need brackets !
    "Select U_tno, U_cpro from [@MX_N301]"
    regards
    David

  • Which Table Store the Query in the Query Manager?

    Hello, I have looking for the table which store all the query inside the Query Manager.
    From this i can retrieve the query without open the program.
    Please help. Thanks.

    Hi William,
    Try this Queries in MSSQL Server Management Studio and dont use Query Generater.
    1. Run this Query, Result: Query Manager Details
    SELECT * from OQCN
    2. Run this Query, Result: Query Details on Query Manager
    SELECT * from OUQR
    Regards,
    Madhan.

  • Can't add own application to RemoteApps - "You must specify a file from the RD Session Host server SERVERNAME by using the UNC path....

    Hi, there
    I'm not really pro- at RDS in server 2012 (r1), but I have a problem and don't find anything suitable on internet:
    I'm trying to publish one of my own, unlisted programs to rdweb, but it keeps saying "You must specify a file from the RD Session Host server SERVERNAME by using the UNC path...."
    1) I provided the path in the unc name - when I click "Add.." then i browse the the .exe file via network share, not via local path. So that should be OK
    2) Firewall is turned off and eventhough the exeptions are enabled, both of then, checked
    What else should I do to make this work?

    Okej, I found the sollution:
    You have to specify the path like \\hostname\drive_letter$\path-to-the-program.
    I was doing wrong because i wrote it like \\hostname\ShareName\path-to-the-program.
    I was misleded because the wizard wants me to find the program by clicking, and not by entring the path manualy.

  • Query Manager Tables

    I see that the OQCN table holds the Query Manager Categories. Does anyone know which DB table holds the actual query name and where, if anywhere, the sql itself is held.
    Thanks

    OUQR table, QName and QString.

  • Tables related to the Query Manager

    I have been looking for the table that hold the data on preformatted queries.
    I found the OUQR table which shows the basics of every query in teh Query Manager.
    What other table(s) have data related to the queries in teh Query Manager.

    Great,  is there any other tables.
    When I run a query it states I have 255 charactors but shows no table info.
    Other then the OUQR and OQCN, is there another table(s) that contain more data on the queries?
    Thanks

  • Results table difference when running query from Alert compared to Query Manager

    Hello,
    I have following query - Aim is to create alert to tell employee which customers to make visit to in next 4 weeks
    SELECT DISTINCT T1.CardName, T1.U_VisitDue, T1.U_VisitReason, T1.U_Priority, T1.U_Region as 'Area', T1.U_VNotes
    FROM dbo.OCRD T1
    WHERE DateDiff(d,T1.U_VisitDue, GETDATE()) <29
    Group BY T1.CardName, T1.U_VNotes, T1.U_VisitDue, T1.U_VisitReason, T1.U_Priority, T1.U_Region
    FOR BROWSE
    My problem is that when I run query through alert the field U_VNotes is displayed differently.
    Running the query from Query Manager the contents of this field appear in one field of the result table.
    Running the query via Alery the content of this field is split into several fields in results table according to 'new line' in field entry.
    This makes the results table from the Query less 'user-friendly' because if you want to sort the table by 'Date' column for example it makes a mess of the table because of the extra rows.
    I want results table to look like top version in picture below ... but i want to run from alert.
    Is this possible?
    How can I achieve it?
    Thanks for any assistance
    Regards, Karen

    Hi
    check this support note:1774628 The SQL SELECT DISTINCT Statement does not work in ALERTS
    Kind regards
    Agustín Marcos Cividanes

  • Is it possible to use Apple Configurator to do a remote wipe of an iPad? Or must I use the profile manager tool within OS X Server?

    Is it possible to use Apple Configurator to do a remote wipe of an iPad? Or must I use the profile manager tool within OS X Server?

    no apple configurator connects via usb
    you'll need a MDM solution such as OSX server profile manager for remote wipe
    OTA pushing profies remote wipe etc
    you could use icloud for remote wipe

  • Could not delete from specified table?

    hi all,
    i'm getting this error could not delete from specified table when i execute a delete on dbf file via JDBC-ODBC bridge, when i execute an update table command i get operation must use an updatable query, but i'm not updating the query returned from select statement.
    Does anyone have similar problem before??

    Hi,
    my code is below:
    try {     
    conn=DriverManager.getConnectio("jdbc:odbc:sui","","");
    stmt = conn.createStatement();     
    int r= stmt.executeUpdate("Update Alarms set ACK=True WHERE DT = { d '" + msgdate + "' } AND TM= '" + msgtime + "'");
    System.out.println(r+" records updated in Alarms ");
    stmt.close();
    conn.close();
    stmt=null;
    conn=null;
    catch (NullPointerException e) {System.out.println(e.getMessage());}
    catch (SQLException e) {System.out.println(e.getMessage());}
    I have an ODBC datasource called sui and a table called alarms, i need to write into the column Ack to true when DT equals msgdate and TM equals msgtime, the error returned is Operation must use an updatable query.
    I believe the SQL has no problem because there is no SQL syntax error and i'm not updating any resultset returned from select query.
    When i delete, i get could not delete from specified table. Anyone has any idea wh'at's wrong?

Maybe you are looking for