Query not executing on production but on dev server

Hi,
I have few queries which are running in less then a second in development server but couldn't get executed on production server in three hours. Production box is much heavier then the development server. I have verified the init.ora parameters. both the boxes have same parameters and same data. How should I start the investigation on the same problem?
Need urgent help.
Thanks is Advance.
Thanks, Dewan

user463820 wrote:
Production box is much heavier then the development server. I have verified the init.ora parameters. both the boxes have same parameters and same data.Which might be a contributing factor to:
I have few queries which are running in less then a second in development server but couldn't get executed on production server in three hours. Do you have QA environment with production-like data? In any case, make sure statistics is collected and is up to date. Get explain plan for queries in question. See if execution plan isn't optimal.
SY.

Similar Messages

  • Authorization object CRM_ORD_OE is not woring in Production but in DEV

    Hi,
    In CRM system authorization object for sales office is working fine in DEV and Quality but not working in PRD.
    What will be the necessary steps to identify the mistake to trace the above mentioned issue?
    Thanks..
    Pranab

    Hi Alex,
    I had that option in front of me ( we actually tried it also with no result ). But before that I would like to know, why this might have happened. Why there is difference between standard menu on both servers?
    Regards,
    Shamish

  • Query execution slow on Production but fine on test DB

    Oracle database : 11.1.0.7.0
    Hi all ,
    There is a query which is taking more than one hour to execute on production but executes within 4 minutes.
    I generate the statspack report on both and this is what it says:
    On Production(taken at a duration of 13 min)
    Instance CPU
    ~~~~~~~~~~~~ % Time (seconds)
    Host: Total time (s): 12,980.
    Host: Busy CPU time (s): 836.4
    % of time Host is Busy: 6.4
    Instance: Total CPU time (s): 820.0
    % of Busy CPU used for Instance: 98.0
    Instance: Total Database time (s): 823.3
    %DB time waiting for CPU (Resource Mgr): 0.0
    Virtual Memory Paging
    ~~~~~~~~~~~~~~~~~~~~~
    KB paged out per sec: 952,086,497.1
    KB paged in per sec: ##############
    Instance Activity Stats DB/Inst: ABDCRS/abdcrs Snaps: 6-7
    Statistic Total per Second per Trans
    buffer is not pinned count 73,698,340 90,761.5 383,845.5
    buffer is pinned count 2,115,542,366 2,605,347.7 ############
    bytes received via SQL*Net from c 439,101 540.8 2,287.0
    bytes sent via SQL*Net to client 223,265 275.0 1,162.8
    calls to get snapshot scn: kcmgss 54,195 66.7 282.3
    calls to kcmgas 1,316 1.6 6.9
    calls to kcmgcs 129 0.2 0.7
    cell physical IO interconnect byt 432,079,872 532,118.1 2,250,416.0
    change write time 62 0.1 0.3
    concurrency wait time 14 0.0 0.1
    consistent changes 843 1.0 4.4
    consistent gets 77,570,007 95,529.6 404,010.5
    consistent gets - examination 40,685 50.1 211.9
    consistent gets direct 0 0.0 0.0
    consistent gets from cache 77,570,007 95,529.6 404,010.5
    consistent gets from cache (fastp 77,523,523 95,472.3 403,768.4
    cursor authentications 0 0.0 0.0
    opened cursors cumulative 49,290 60.7 256.7
    On test Database (taken at a interval of one and a half min)
    Instance CPU
    ~~~~~~~~~~~~ % Time (seconds)
    Host: Total time (s): 134.0
    Host: Busy CPU time (s): 37.1
    % of time Host is Busy: 27.7
    Instance: Total CPU time (s): 26.5
    % of Busy CPU used for Instance: 71.5
    Instance: Total Database time (s): 100.5
    %DB time waiting for CPU (Resource Mgr): 0.0
    Virtual Memory Paging
    ~~~~~~~~~~~~~~~~~~~~~
    KB paged out per sec: 6.8
    KB paged in per sec: 26.1
    Instance Activity Stats DB/Inst: ABDCRS/abdcrs Snaps: 2-3
    Statistic Total per Second per Trans
    buffer is not pinned count 799,850 11,762.5 49,990.6
    buffer is pinned count 458,511 6,742.8 28,656.9
    bytes received via SQL*Net from c 888,978 13,073.2 55,561.1
    bytes sent via SQL*Net to client 5,980,608 87,950.1 373,788.0
    calls to get snapshot scn: kcmgss 245,953 3,617.0 15,372.1
    calls to kcmgas 818 12.0 51.1
    concurrency wait time 2 0.0 0.1
    consistent changes 7 0.1 0.4
    consistent gets 1,037,292 15,254.3 64,830.8
    consistent gets - examination 421,021 6,191.5 26,313.8
    consistent gets direct 96,012 1,411.9 6,000.8
    consistent gets from cache 941,280 13,842.4 58,830.0
    consistent gets from cache (fastp 358,400 5,270.6 22,400.0
    current blocks converted for CR 0 0.0 0.0
    opened cursors cumulative 239,029 3,515.1 14,939.3
    Now as u can see the value for " bytes sent via SQL*Net to client" on test is very high for a one min window but on prod it is very low even for a 13 min window also value for consistent gets on prod in extremely high as compared to test database and test db is doing more execution in one min than prod database in 15 min.Now these are the major differences on prod and test could this be the reason for slow execution of query on prod? and how do I fix it
    Also value for opened cursors cumulative for test is high but it is low on prod.I don't have the awr report as database is standard edition Looking forward to your reply
    Thanks
    Saurav

    Pl use \ tags to make your post more readable - http://wiki.oracle.com/page/Oracle+Discussion+Forums+FAQ
    When your query takes too long:
    HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long ...
    HTH
    Srini                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • I have a problem with Adobe Creative Cluod. Basically after installing the application when I open it I do not charge adobe products but remains all white screen. I tried to uninstall it and install it several times but it does not work.  What should I do

    I have a problem with Adobe Creative Cluod. Basically after installing the application when I open it I do not charge adobe products but remains all white screen. I tried to uninstall it and install it several times but it does not work.
    What should I do?

    Hi Anto2211,
    Please follow the thread: Black screen CC where this issue is already discussed and resolved.
    Let me know for any further query.
    Thanks,
    Ratandeep Arora

  • SAP standard Menu : few menu paths not visible in Production but dev

    Hi All,
    We have a problem where in we can see the following menu path visible in standard menu in developement system; while the same menu path ( and few others also ) not visible in production system for same user ( i.e. having similar authorizations )
    the path is :  SAP Menu --> Accounting --> Financial Supply Chain Management --> Cash and Liquidity Management
    Our system is : ECC 6.0
    Every user should be able to view SAP standard menu inspite of the fact that he might have authorization to certain transactions only; hence this should not be an authorization issue ( as per my view ).
    So can anybody help/ suggest in this regard?
    Thanks.
    Regards,
    Shamish

    Hi Alex,
    I had that option in front of me ( we actually tried it also with no result ). But before that I would like to know, why this might have happened. Why there is difference between standard menu on both servers?
    Regards,
    Shamish

  • DataSource is "NOT EXECUTABLE" in Production

    Hi,
             We are working on BI 7.0 and trying to move the objects of my module in to Production.
              One Generic DataSource(Master Data Attribute) has been first transported in to Production R/3 , from there I replicated this DataSource in Production BI...and symultaneously all the related objects related to this DataSources were also transported from Dev BI to Production BI.
    in RSA6, I checked Object Directory entry for that particular DataSource...It's perfectly locked under particular Package and in my own request.
    Still, when I replicated it from Production R/3 to Production BI, it's not properly activated...means....the version is showing as "ACTIVE", But Active Version as "NOT EXECUTABLE"(Edited Version) .... and the datasource is not highlighted with green color....
    Can somebody  help me in finding what could be the error and appropriate solutions....
    Thanks guys......Intros

    Hi,
    Are you using 3.x data source or 7.0 data source.
    In case you are using 3.x data source make sure you have replicated the data source as a 3.x data source in to BW.
    Please use function module RSAOS_DATASOURCE_ACTIVATE
    and check the error message you are getting.
    Regards,
    Nitin

  • Sql query not executed using recordset

    Hi All,
    I am trying to first format and then execute SQL query statement using recordset object with DI API. the issue is with vb.net's string formatting. I want to use 'USE [DB_Name]' statement in SQL and then 'Alter Procedure ..' statement. as this has to be the first statement in sql , I am using 'GO' in between and seperating each sentence with following syntax.
      Dim AltProc  as string
      AltProc = " USE [DB_name]" & Environment.NewLine
      AltProc = AltProc & " GO " &  Environment.NewLine
      AltProc = AltProc & " ALTER proc [proc_name] " &  Environment.NewLine
    '---------------------and so on
    Orec.DoQuery(AltProc)
    this formatting does not recognize new line and gives 'incorrect syntax near 'Go'' error.  strange thing is, if I take this query in SQL, it runs perfectly and I can see it getting formatted with each new line created. I tried even VbcrLf but it didnt work.
    any one has any idea?
    thanks in advance,
    Binita

    HI Binita
    The reason:
    GO is the "command" delimiter of MS Query Editor.
    It is not working with RecordSet Object.
    In MS SQL 2008 version you can define the schema before the procedure name but in SQL server 2000/2005 it is not possible.
    IN SQL 2008 use the Fully Qualified name instead of GO:
    Dim AltProc  as string
      AltProc = " ALTER proc [DB_name].[dbo].[proc_name] "  + vbcrlf
    '---------------------and so on
    Orec.DoQuery(AltProc)
    it is not working on MS SQL 2008 i have tried.
    'CREATE/ALTER PROCEDURE' does not allow specifying the database name as a prefix to the object name.'
    Regards,
    J.
    Edited by: Janos  Nagy on Jun 22, 2009 2:55 PM

  • QBE style(Find-Execute) Query not executing when VO has bind parameter

    I have an Entity Based ViewObject that is composed of 3 Entities so the entities are related through an Assoc. Then the ViewObject also has a bind paremeter defined and used in the WHERE clause.
    In my page everything is fine until when I use/click on the Find operation on the JSF page. When the Find operation is executed the page/form goes blank so I can enter by QBE query. Now when I Execute my search by executing the ExecuteWith params operation. Nothing is happening to the screen, it seems that query was not executed. Although there was no errors or exceptions displayed.
    However if I remove the bind parameter, and execute the Execute operation instead after going to Find mode, the query is executed properly and I get expected results.
    My problem is a bit general, but are there anyone who had a similar problem like this? Im still in the process of creating a test case.
    regards,
    Anton

    Hi Frank,
    But the "ExecuteWithParams" operation provides the bind variable right? (i had the value hardcoded on the pagedef). So it must have supplied a value. I also noticed that this is happening only when if the VIewObject contains two or more Entities. If the Viewobject has only 1 entity, the ViewObject queries properly.
    Anyway Frank, I had found a fix for this. I set an InvokeAction on the pagedef that binds to the ExecuteWithParams that is invoked during page load only(!postback condition). and then I just use the Find-Execute operations instead of the Find-ExecuteWithParams operations that I used previously.
    I will try to replicate the issue again to investigate what's really going on. I just want to know if its a bug or just an expected behavior or i just made a mistake.
    regards,
    Anton

  • Database migration query not executing in database

    We moved over our SQL database to another server. We have a few .cfm template files that have queries to get 'content' from our database. These queries in the .cfm template files work fine and execute properly. However, for some reason, since we moved over our database, the queries in the actual database don't execute/run anymore. In the old server we didn't have this problem. Our queries in the database would run properly then. The data would display correctly on the webpages.
    Is there some kind of properties setup that was overlooked when migrating over our database?
    The output we now see when viewing our pages is the actual query code.
    Example:
    SELECT lname
    FROM table
    This is actually displayed on the website and therefore the query is not executing/running. Our code was never changed. So why is it not outputting the same?
    Thanks for any help provided.

    Sorry for the confusion.
    The coldfusion templates and database queries both worked fine on the previous old server.
    Now since the migration onto the new server, only the coldfusion templates work fine, but not the queries in the database.
    So for example, a query in the coldfusion template will run fine, and execute the intial pull of data. But once the content is pulled from the database, the queries inside the database (including stored procedures) don't execute.
    We do get the expected results when we run our stored procedure in Management Studio and if we put the stored procedure on a standalone web page we do see the records. 
    We only see the sql code when we have the stored procedure inside of our w_content table of our database, and its being called by the first query in the template.  For some odd reason the stored procedure does not execute if it is inside the database.  
    Hopefully that clarifies our problem.
    Thank you for helping!

  • Query not executing for one particular value

    Hi
    I have query on multi provider. and this multi provider is combination of Info objects only but not any ODS or cubes. I have one key figure in this multi provider.while executing the query i need to give input for variabl which has 7 different values. Query is executing fine for 6 values but not for one particular value.
    query executed in listcube transaction and it is executed fine here for the same selection. then what might be the reason?
    Please advise as soon as possible.
    Thanks

    Hi Kiran,
    are you maintaining any filters in the query? or is there any logic in the exit for this variable.
    regards.

  • Trigger query not executed and havenot any exception

    Hello all,
    I am using oracle 10g lite database, and i m firing a create trigger query, but it is not executed on console, when i try at console at this trigger query after that no one query will fire,
    Plzzzzzzzzzzzzzzzzzzz help me
    my used table is
    1. create table t1 ( c1 int, c2 int);
    2. create table t2 (c1 int, c2 int);
    3. Create trigger System.check after insert on system.t1 For each Row begin Insert Into system.t2 ( c1,c2 ) Values (1,1) ;end ;
    Thankx in advance
    Pankaj

    Triggers are supported on the client side in newer versions:
    11.2.1 Creating Java Stored Procedures
    To create a stored procedure, perform the following:
    1.
    Create the class that you want to store in Oracle Database Lite. You can use any Java IDE to write the procedure, or you can simply reuse an existing procedure that meets your needs.
    When creating the class, consider the following restrictions on calling Java stored procedures from SQL DML statements:
    When called from an INSERT, UPDATE, or DELETE statement, the method cannot query or modify any database tables modified by that statement.
    When called from a SELECT, INSERT, UPDATE, or DELETE statement, the method cannot execute SQL transaction control statements, such as COMMIT or ROLLBACK.
    Note:
    Any SQL statement in a stored procedure that violates a restriction produces an error at run time.
    2.
    Provide your class with a unique name for its deployment environment, since only one Java Virtual Machine is loaded for each Oracle Database Lite application. If the application executes methods from multiple databases, then the Java classes from these databases are loaded into the same Java Virtual Machine. We recommend that you prefix the Java class name with the database name to ensure that the Java class names are unique across multiple databases.
    3.
    If you are executing any DML statements in your Java stored procedure, then—in order for these statements to exist within the same transaction—you must pass an argument of type java.sql.Connection as the first argument in the method. You must have the Connection object in order to prepare and execute any statements. Oracle Database Lite supplies the appropriate argument value of the Oracle Lite database Connection object for you; the application executing the method does not need to provide a value for this parameter.

  • OSS note is not working in production but works correctly in test system .

    hello friends ,
    weh have implemented one OSS notes , which is working corectly in Test system , but not working in production .
    Could you please let me know , what could be the reason ?
    OSS note no 1064273-
    Regards,
    Manoj

    Pls. check with Basis if the OSS note has been implemented properly and successfully.

  • Query not executing with "Insufficient Shared Objects Memory Available"

    Hi ,
    We have few Reports on a Multi provider, which are working fine earlier both in Web Analyzer and  Bex Analyzer.
    Now we have created an Entry in the MULTIPROVIDER  Hint table  as we have data based on Fiscal Year in 3 different cubes.
    This went fine in our quality system and even it is working now. The reports worked fine  in Production earlier.
    After the change( moving HInt tables entries) queries are not working and givig an error message.
    But if I exeute the reports in Production I get the above mentioned error message.
    1. Have regenerated the Queries already  in Production.
    2. No changes to the Reports.
    3. No changes to the Multi provider.
    Only change is introduction of an entry in Hint table.The same functaionality which is working in quality system is not working in Production.
    We have same amount of data both in our quality and Production for some set of selections.
    Please share your thoughts/experineces if anyone have worked on this.
    Regards,
    Ganesh Thota.

    Hi,
    Try to inrcrease paramenter abap/shared_objects_size_MB as described in SAP Note 972757.
    BR,
    Walter Oliveira

  • Query not executing the results

    Hi,
    I have created a Custom Virtual Cube with a custom function module. This Cube displays data when i check it through the transaction code - LISTCUBE.
    I have a query which has to be executed on this Virtual Cube. When i execute this Query , it does not display any data at all. It always displays "No applicable data found".
    I have tried with the combination of inputs for which the data is available in the cube. but still it gives "No applicable data found".
    Can someone suggest me what i have to do to correct this problem.
    Thanks
    Maddy

    Hi Maddy,
    I also encountered similar problem in BI 7.0, which doesn't happen in BW 3.5, though I was using Basic Cube, not Virtual Cube. I could finally work it out. Here are the steps I used:
    - Right click on the InfoCube > choose "Manage".
    - In the "Requests" tab, click the traffic light button in the "Request Status" column, set it to "Status OK".
    - The "Request for Reporting Available" column will show the "Request is available for reporting" icon automatically.
    - Try to execute your query again.
    Hope this might be relevant to your situation as well.
    Regards,
    arie

  • Query not executing all columns

    Hi Experts
    My client is running a query. they have been using it for a little while now with no issues. I have attached the query as a formatted search on the item master data form. when one of their users runs the queriy through the formatted search, it doesnt show the last column. but when running it through the query manager, it works fine.
    its only giving this problem for the one user (doesnt matter if we log in as that user on his PC or any other PC) therefore it is user related.
    why could this be happening?

    OK below is the query:
    declare @CurUser as nvarchar(10)
    set @CurUser = $[user]
    if(@CurUser in (1,5,8,9,22,44
    begin
    with req as
    select [item number] as 'item',[required qty] as 'required', [forecast current month] as 'forecast', [sq] as 'SQ', [on hand]
    FROM VPP_2006SBO_GARSINLIVE.DBO.VLGX_GetPlannedItemDetails()
    Invoices AS  --Get invoices per item
    *(SELECT T0.[ItemCode], T0.[FrgnName], SUM(I1.[Quantity]) AS Qty,*
            *DATEDIFF(month, T0.CreateDate,getdate()) AS ItemMonths*            
       *FROM OITM T0  full outer join inv1 i1 on T0.ItemCode = I1.ItemCode*
                     *left join OINV I0 ON I0.DocEntry = I1.DocEntry*
      *WHERE I0.[DocDate] >= '2006-06-01'*
        *AND I0.DocType <> 'S'*
      *GROUP BY T0.[ItemCode], T0.[FrgnName], T0.CreateDate*
    *Credit AS               -- Get credit notes per item*
    (      SELECT C1.[ItemCode],
    *                C1.[Dscription],*
    *                SUM(C1.[Quantity]) AS Qty*
    *          FROM ORIN C0  INNER JOIN RIN1 C1 ON C0.DocEntry = C1.DocEntry*
           WHERE C0.[DocDate] >= '2006-06-01'
                 AND C0.DocType <> 'S'
          GROUP BY C1.[ItemCode], C1.[Dscription]
    ItemInfo As
    (SELECT T0.ItemCode[SearchCode], t0.ItemName,T0.FRGNName[Description], cast (cast ((T0.OnHand- T0.IsCommited) as decimal (5,0)) as nvarchar (10))[Available], cast (cast (T0.OnOrder as decimal (5,0)) as nvarchar (10))[Expected],
    (case when (T0.U_IMP is null or T0.U_IMP = '')  then '0' else T0.U_IMP end )as 'InputTube',
    *(T0.U_Wieghtm * T0.BLength1)[KgLength], T0.ValidComm[-], T2.Price[PriceL],  T0.SWW[Spec],T0.U_ManStd, T0.U_MaterialSpec,T0.U_WIEGHTM[KgMetre],* 
    (T2.Price/(CASE WHEN T0.BLength1 = 0 THEN 0.0001 ELSE T0.BLength1 END))[PriceM]
    FROM OITM T0  INNER JOIN ITM1 T2 ON T0.ItemCode = T2.ItemCode,
    OCRD T3
    WHERE T3.CardName = '[%1]'
    and LEFT(T0.ITEMCODE,1)<>'L'
    and t0.itmsgrpcod <> '105'
    and t0.itmsgrpcod <> '101'
    and t0.itmsgrpcod <> '112'
    and t0.itmsgrpcod <> '113'
    and t0.itmsgrpcod <> '111'
    and t0.itmsgrpcod<>'114'
    and T2.[PriceList] = T3.[ListNum]
    and T3.CardType = 'C'        
    --order by T0.ITEMNAME
    SELECT
    ITEMINFO.SearchCode,
    --iteminfo.itemname,
    ITEMINFO.Description,
    ITEMINFO.Available,
    (case when ITEMINFO.Expected is null then '0' else ITEMINFO.Expected end ) as 'Expected',
    (case when req.forecast is null then 0 when req.forecast = 0 then 0 when req.forecast > 0 then (iteminfo.available + (case when ITEMINFO.Expected is null then 0 else ITEMINFO.Expected end)) / (case when req.FORECAST is null then 0 else req.FORECAST end)end) as 'Months Left of Stock',
    --(case when Inv.[Qty] is null then Inv.[Qty]  else Inv.[Qty] end) as 'i qty',
    --(case when Crn.[Qty] is null then Crn.[Qty]  else Crn.[Qty] end) as 'c qty',
    --(case when Inv.ItemMonths is null then Inv.ItemMonths else Inv.ItemMonths end) as 'Invoice ItemMonths',
    (case when  (Inv.[Qty] is null or Crn.[Qty] is null) and Inv.ItemMonths is null then '0' when Inv.[Qty] is null then '0' when Inv.ItemMonths ='0' then Inv.[Qty] when Crn.[Qty] is null and Inv.[Qty] >=0 then (Inv.[Qty] / Inv.ItemMonths) ELSE ((Inv.[Qty] - Crn.[Qty]) / Inv.ItemMonths) END) AS 'Garsin Avg Sales Per Month',
    (case when req.FORECAST is null then '0' else req.FORECAST end) as 'Valogix Avg Sales Per Month',
    (case when ITEMINFO.InputTube is null then '0' else ITEMINFO.InputTube end) as 'Input Tube',
    (case when ITEMINFO.KgLength is null then '0' else ITEMINFO.KgLength end) as 'Kg Length',
    (case when ITEMINFO.PriceL is null then '0' else ITEMINFO.PriceL end) as 'Price L' ,
    (case when ITEMINFO.Spec is null then '0' else ITEMINFO.Spec end) as 'Standard/Non-Standard', Iteminfo.U_MaterialSpec as 'Material Grade',
    (case when iteminfo.U_manstd is null then ' ' else iteminfo.U_manstd end) as 'Manufacturing Standard' ,
    (case when ITEMINFO.KgMetre is null then '0' else ITEMINFO.KgMetre end) as 'Kg Metre',
    (case when Iteminfo.PriceM is null then '0' else Iteminfo.PriceM end) as 'Price M'
    FROM Invoices Inv left outer JOIN Credit Crn ON Inv.[ItemCode] = Crn.[ItemCode]
                      full outer join ItemInfo  ON Inv.[ItemCode] =ItemInfo.[SearchCode]
    *                         left outer join req on req.item =  iteminfo.searchcode collate SQL_Latin1_general_CP850_CI_AS     *
    where Iteminfo.SearchCode is not null
    GROUP BY iteminfo.itemname , ItemInfo.[SearchCode], ItemInfo.[Description],Iteminfo.Available, Inv.Qty, Crn.Qty, Inv.ItemMonths, Iteminfo.Expected, ItemInfo.InputTube, ItemInfo.KgLength, Iteminfo.PriceL, ItemInfo.Spec,iteminfo.U_manstd,Iteminfo.Kgmetre, Iteminfo.U_MaterialSpec,ItemInfo.PriceM,req.FORECAST
    order by iteminfo.itemname
    end
    else
    begin
    WITH Invoices AS  --Get invoices per item
    *(SELECT T0.[ItemCode], T0.[FrgnName], SUM(I1.[Quantity]) AS Qty,*
            *DATEDIFF(month, T0.CreateDate,getdate()) AS ItemMonths*            
       *FROM OITM T0  full outer join inv1 i1 on T0.ItemCode = I1.ItemCode*
                     *left join OINV I0 ON I0.DocEntry = I1.DocEntry*
      *WHERE I0.[DocDate] >= '2006-06-01'*
        *AND I0.DocType <> 'S'*
      *GROUP BY T0.[ItemCode], T0.[FrgnName], T0.CreateDate*
    *Credit AS               -- Get credit notes per item*
    (      SELECT C1.[ItemCode],
    *                C1.[Dscription],*
    *                SUM(C1.[Quantity]) AS Qty*
    *          FROM ORIN C0  INNER JOIN RIN1 C1 ON C0.DocEntry = C1.DocEntry*
           WHERE C0.[DocDate] >= '2006-06-01'
                 AND C0.DocType <> 'S'
          GROUP BY C1.[ItemCode], C1.[Dscription]
    ItemInfo As
    (SELECT T0.ItemCode[SearchCode], t0.ItemName,T0.FRGNName[Description], cast (cast ((T0.OnHand- T0.IsCommited) as decimal (5,0)) as nvarchar (10))[Available], cast (cast (T0.OnOrder as decimal (5,0)) as nvarchar (10))[Expected],
    (case when (T0.U_IMP is null or T0.U_IMP = '')  then '0' else T0.U_IMP end )as 'InputTube',
    *(T0.U_Wieghtm * T0.BLength1)[KgLength], T0.ValidComm[-], T2.Price[PriceL],  T0.SWW[Spec], T0.U_MaterialSpec,T0.U_WIEGHTM[KgMetre],* 
    (T2.Price/(CASE WHEN T0.BLength1 = 0 THEN 0.0001 ELSE T0.BLength1 END))[PriceM]
    FROM OITM T0  INNER JOIN ITM1 T2 ON T0.ItemCode = T2.ItemCode,
    OCRD T3
    WHERE T3.CardName = '[%1]'
    and LEFT(T0.ITEMCODE,1)<>'L'
    and t0.itmsgrpcod <> '105'
    and t0.itmsgrpcod <> '101'
    and t0.itmsgrpcod <> '112'
    and t0.itmsgrpcod <> '113'
    and t0.itmsgrpcod <> '111'
    and t0.itmsgrpcod<>'114'
    and T2.[PriceList] = T3.[ListNum]
    and T3.CardType = 'C'        
    --order by T0.ITEMNAME
    SELECT
    ITEMINFO.SearchCode,
    --iteminfo.itemname,
    ITEMINFO.Description,
    ITEMINFO.Available,
    (case when ITEMINFO.Expected is null then '0' else ITEMINFO.Expected end ) as 'Expected',
    (case when ITEMINFO.InputTube is null then '0' else ITEMINFO.InputTube end) as 'Input Tube',
    (case when ITEMINFO.KgLength is null then '0' else ITEMINFO.KgLength end) as 'Kg Length',
    (case when ITEMINFO.PriceL is null then '0' else ITEMINFO.PriceL end) as 'Price L' ,
    (case when ITEMINFO.Spec is null then '0' else ITEMINFO.Spec end) as 'Standard/Non-Standard', Iteminfo.U_MaterialSpec as 'Material Spec',
    (case when ITEMINFO.KgMetre is null then '0' else ITEMINFO.KgMetre end) as 'Kg Metre',
    (case when Iteminfo.PriceM is null then '0' else Iteminfo.PriceM end) as 'Price M'
    FROM Invoices Inv left outer JOIN Credit Crn ON Inv.[ItemCode] = Crn.[ItemCode]
                      full outer join ItemInfo  ON Inv.[ItemCode] =ItemInfo.[SearchCode]
    where Iteminfo.SearchCode is not null
    GROUP BY iteminfo.itemname , ItemInfo.[SearchCode], ItemInfo.[Description],Iteminfo.Available, Inv.Qty, Crn.Qty, Inv.ItemMonths, Iteminfo.Expected, ItemInfo.InputTube, ItemInfo.KgLength, Iteminfo.PriceL, ItemInfo.Spec,Iteminfo.Kgmetre, Iteminfo.U_MaterialSpec,ItemInfo.PriceM
    order by iteminfo.itemname
    end
    >>BASICALLY THERE ARE 2 QUERIES BUILT INTO ONE. IF THE USERCODE IS 1,5,8,9,22, OR 44 THEN IT WILL EXECUTE THE FIRST PART OTHERWISE IT EXECUTES THE OTHER PART. THIS ISNT THE ISSUE WTH MY QUERY AS I HAVE CHECKED THE USERCODE.

Maybe you are looking for