Converting microsoft sql server documents into portal items

Our customer currently has a number of documents
stored in a Microsoft SQL server database as an
'image' datatype.
They would like to programatically move all these documents from the sql server into the portal database and store them as portal items (we are using 9.0.2.6) Has anyone done something like this before?
Any thoughts would be appreciated.
Thanks,
Suzanne

The API documentation discusses the requirements for calling the APIs from an external environment. Assuming you will use a language like Java through JDBC, you just open connections to the two databases. The APIs are called just like any other stored procedure. You'll have to read the language-specific and database-specific documentation for instructions on handling LOBs e.g. the Oracle9i JDBC Developer's Guide and Reference.
Regards,
Jerry
PortalPM

Similar Messages

  • SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)

    SAP query error - 1). [Microsoft][SQL Server Native Client 10.0][SQL Server]Conversion failed when converting date and/or time from character string.  'Received Alerts' (OAIB)
    SELECT    
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO AS T0 LEFT OUTER JOIN
                          VPM2 AS T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry LEFT OUTER JOIN
         OVPM AS T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1 AS T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate>='[%0]' and T0.DocDate<='[%1]'

    Hi,
    Try this:
    SELECT   
    CASE WHEN T0.DocStatus = 'O' THEN 'OPEN'
    WHEN T0.DocStatus = 'C' THEN 'CLOSED'  END  AS 'Document Status',
    T0.DocDate AS 'Posting Date',
    T0.DocNum AS 'Doc.No',
    T0.NumAtCard,
    T0.TransId AS 'Trans. No.',
    T0.Comments AS 'Remarks',
    T0.CardCode AS 'Offset Acct',
    T0.CardName AS 'Offset Acct Name',
    sum(T0.DocTotal) + (T0.WTSum) as 'DocTotal',
    T3.DueDate AS 'Cheque Date',
    T3.CheckSum AS 'Amount'
    FROM         ODPO  T0 LEFT OUTER JOIN
                          VPM2  T1 ON T0.ObjType = T1.InvType AND T0.DocEntry = T1.DocEntry
    LEFT OUTER JOIN
         OVPM  T2 ON T2.DocEntry = T1.DocNum LEFT OUTER JOIN
                          VPM1  T3 ON T2.DocEntry = T3.DocNum
    where T0.DocDate >= '[%0]' and T0.DocDate <='[%1]'
    group by T0.DocStatus,T0.DocDate ,
    T0.DocNum ,
    T0.NumAtCard,
    T0.TransId ,
    T0.Comments ,
    T0.CardCode,
    T0.CardName ,
    T0.WTSum ,
    T3.DueDate ,
    T3.CheckSum
    Thanks & Regards,
    Nagarajan

  • [Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.  'Items' (OITM) (OITM)

    Dear Experts,
    i am getting the below error when i was giving * (Star) to view all the items in DB
    [Microsoft][SQL Server Native Client 11.0][SQL Server]The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.  'Items' (OITM) (OITM)
    As i was searching individually it is working fine
    can any one help me how to find this..
    Regards,
    Meghanath.S

    Dear Nithi Anandham,
    i am not having any query while finding all the items in item master data i am giving find mode and in item code i was trying to type *(Star) and enter while typing enter the above issue i was facing..
    Regards,
    Meghanath

  • Is there a way to convert Crystal Reports to Microsoft SQL Server 2005 reporting services?

    Post Author: Lourdes Hernandez
    CA Forum: General
    Our department has always worked with and we love Crystal Reports. Unfortunately, certain reports now need to be converted to Microsoft SQL Server 2005 reporting services which from what I read I think they are *.rdl reports. Does Crystal reports have any way around this? I would have to learn this other tool when I'm already so happy with Crystal. I was thinking If I could just code the report in crystal and export it in a specific format that would be compatible Microsoft, the problem would be solved.
    Any ideas would be greatly appreciated.

    Post Author: bettername
    CA Forum: General
    Ditto!
    There are some software packages to convert from CR to RS, but none work 100% AFAIK, and will require manual tuning.
    Seems like a big hassle and learning curve just to get reports published via another method - I know I'd put up huge resistance if they tried to take my CR away from me!

  • Move datafiles and logfiles (Portal 6.0 and Microsoft SQL Server 2000)

    Hello,
    I have installed EP 6.0 with KMC and TREX. The database is MS SQL Server 2000.
    The datafiles and the logfiles of the portal are respectively located in the directory "C:\Program Files\Microsoft SQL Server\MSSQL\Data" and in "C:\Program Files\Microsoft SQL Server\MSSQL\LOG".
    I want to move these files in the disk D.
    How can I do it ?
    Is the procedure described in the site http://support.microsoft.com/kb/224071 correct ?
    I thank you for your help.
    Regards,
    Anne-Marie

    Francesc,
    Microsoft Exchange Server Integration in EP6.0
    The Microsoft Exchange server (subsequently called the Exchange server) is integrated using the Microsoft Exchange server transport. This transport integrates the scheduling capabilities of Exchange Server with SAP Enterprise Portal 6.0. The following versions of Microsoft Exchange server can be integrated with the Enterprise Portal.
    · Exchange Server 5.5 SP4
    · Exchange Server 2000
    · Exchange Server 2003
    The transport uses Microsoft Collaborative Data Objects 1.2.1 (subsequently called CDO) to access data from the Exchange server.
    You can check for more details on;
    http://help.sap.com/saphelp_nw04s/helpdata/en/7a/ec015c8446d447a83776d40f31c84f/frameset.htm
    Regards,
    James

  • Converting SQL server database into SAP readable XML??

    Could anyone kindly let me know what is the procedure to convert SQL server database into SAP readable (encrypted) XML for SAP Authoring tool???

    Sorry you will need to be more specific, what is it exactly you want to do? What authoring tool do you mean.
    A bit more info and someone might be able to help you.
    BRgds,
    Simon

  • Convert MS SQL server image data type into oracle clob

    Hi all! I'm tryng to access to Microsoft SQL server with Oracle via ODBC. Oracle is not able to use the image data type of Microsoft SQL server. Do you know a way to convert this data type in an oracle format? The explicit casting converts image to long raw, but after the conversion Oracle is not able to manage these data type. Thank you very much!
    Stefano.

    Hi you might want to post your question in General Forum.
    General Database Discussions
    There's very few users visit this forum.

  • Convert SQL server database into SAP readable (encrypted) XML for SAP tool?

    Could anyone kindly let me know what is the procedure to convert SQL server database into SAP readable (encrypted) XML for SAP Authoring tool???

    So If I understood it correctly there an existing propriertory question bank with SQL server. You are looking at an option to migrate all the tests and questions from the existing system to the LSO system. Right ?
    I am still not clear on the xml conversion. Have you guys found a solution which could be achieved through a xml file ?
    am not aware of a way through which you could import only a xml file and create tests/questions. If you have a sample xml file then forward me so that I could do some testing on my end.As per my knowledge you could do one of the following. I
    1. Create the tests and questions manually in Authoring Environment. It will be a time consuming task. Based on the number of questions you have you might have to assemble a team of content developers to acheive this.
    2. Alternatively, you could create a Adobe Flash based assessment. The Flash component would be the front-end and will read from a xml file to display the questions and to drive the funcationality. This would be a easier and less time consuming than creating the assessments manually in authoring environment. However, you might miss out some of the functionality available in the Test Author of Authoring Environment unless you have all the functionality replicated inside Flash. This would require one time effort in creating the Flash template and the xml file structure. Once that is created you could create multiple assessments by just replacing the xml file. If you select this approach then you would have to ensure the data from SQL is converted in the desired xml format required by your Flash component.
    Please let me know if you require any further guidance or clarification regarding this.
    Regards,
    Ravi Sekhar

  • Writing data to Microsoft SQL Server/Dat​abase

    Hi All
    I have written a program in LV ver 6.1 that carries out various functional tests and at each test gathers 3 data values. At the moment the data is gathered at each stage of the test and written in a concatenated string to a file that was opened at the start of the test routine. What I need to do is output the data such that it is compatable with SQL server (presumably in some form of table?). I have read previous posts but they recommed the ni database toolkit, which I do not have. Should I be using the XML vi to take the string of data or use the active x vi? I have read in other posts that you can manage without the ni database toolkit but would need to program a database structure. My knowledge of database development is nil and I wondered if there was a vi that could be used that would create tables that could be directly interpreted by MS SQL?
    Labview Version 8.5
    Labview Version 8.6
    Labview Version 2013

    I'm having trouble understanding exactly what you're doing, but I will try to explain a few things:
    Ideally code written for database connectivity should not be included in my Labview code or problems could occur if my client changed his servers , database structure etc.
    The code can be yours. If you do write it, just make sure to create subVIs, so that if the DB structure does change (something which is rare), you will only need to change the code inside the subVIs.
    Microsoft SQL server is an intermediate piece of software that allows my Labview code to access the database without actually 'seeing' it. With my client using SQL server they can modify the way my Labview code sends data to their database if they decide to change their servers, database structure etc.
    SQL Server is the DB management system. It holds all the tables, queries, etc. and is responsible for actually managing the DB itself.
    What Dennis suggested was that the DB guy will write something known as a "stored procedure" and that you will call it.
    In such a case, if the DB guy wanted to change something, he could just change the stored procedure and (if the change does not affect the interface), you do not have to change or rebuild your program. This is equivalent to the subVIs I described earlier, except in this case, the function is inside the DB itself.
    Another version of this is creating a table with SQL commands and assigning a name for each command. You load the SQL command from the table by name and execute it. This allows for changing the SQL command inside the DB without changing your application.
    ADO connectivity is used and the connection string is best located in the windows registry file. Presumably this option would give my client the most flexiblity? Is this the same thing as the .udl file?
    Basically, the scheme is like this:
    DB <-> DBMS <-> ODBC <-> ADO <-> Your Application
    This may not be perfectly accurate, but the concept is basically this - in Windows, you talk to ANY database from ANY program using the same interface - you call ADO functions which will be responsible for getting to the DB you want and you use SQL to issue the commands, since the basic SQL commands are supported by all DBs.
    To identify the DB, you use a connection string. This connection string can have all the data in it or it can point to an existing file (UDL or DSN) which holds the data pointing to the DB. Dennis suggested that when developing on your machine, you will use a file pointing to a local DB, but when deploying you will use a file of the same name which will point to the real DB. Your program will always go to the file and from there it will know which DB to go to.
    The only time when this should really matter to the client is during configuration (for example, if the DB was moved to a different machine). All the client needs to do is edit the UDL file to point at the new location of the DB.
    Again, the advantage of all this is that this is not part of your code and is done by programs which are built to handle it.
    It is more efficient to use the Parameterized database technique such as the example given in the 'logging example parameterized'
    I don't know how much this efficiency will be relevant in the speeds you need.
    In any case, as I said, my own preference is to create functional subVIs - for example, a VI which will accept data in my format and will be responsible internally for converting that data and putting it into the necessary tables.
    I have sent my client an outline of the data to be saved on their database, which at the moment comprises of 3 tables, the first has things like operators name, date, time, serial number etc ( 7 records, 3 fields) the second table has test reference (11 tests in total) with items such as fuel flow, fuel temp etc (11 records, 5 fields), Last table has 1 record and 6 fields. Unlike the Labview example each stage of the test can take up to 4 minutes to complete and if successfull the program moves on to the next stage of the test, saving the test results and if a PASS or FAIL occurred. The question I have is would it more efficient to save the results at the end of all of the tests or shold I connect to their database and save results as the tests progress?
    I can't say I understand this, but my suggestion would be to let the client decide in what format they want the data, since they're the ones who want it. Work with the DB guy to decide exactly what data you need to put into the DB and where and then you can decide exactly which functions you need. As said, you might want to let the DB guy write some stored procedures which you can use to input the data.
    Unless it's a large amount of data, writing to a DB is usually fairly quick (under a second). If it is relevant, my suggestion would be to write after each phase.
    In any case, I suggest you go through some real DB tutorials (not LV related) and see if you can wrap your head about it. I know I don't particularly like designing DBs (or PID) any more than you do, but it's a skill worth having, and in some places, a DB makes things easy and practical.
    Try to take over the world!

  • How to convert from SQL Server table to Flat file (txt file)

    I need To ask question how convert from SQL Server table to Flat file txt file

    Hi
    1. Import/Export wizened
    2. Bcp utility
    3. SSIS 
    1.Import/Export Wizard
    First and very manual technique is the import wizard.  This is great for ad-hoc and just to slam it in tasks.
    In SSMS right click the database you want to import into.  Scroll to Tasks and select Import Data…
    For the data source we want out zips.txt file.  Browse for it and select it.  You should notice the wizard tries to fill in the blanks for you.  One key thing here with this file I picked is there are “ “ qualifiers.  So we need to make
    sure we add “ into the text qualifier field.   The wizard will not do this for you.
    Go through the remaining pages to view everything.  No further changes should be needed though
    Hit next after checking the pages out and select your destination.  This in our case will be DBA.dbo.zips.
    Following the destination step, go into the edit mappings section to ensure we look good on the types and counts.
    Hit next and then finish.  Once completed you will see the count of rows transferred and the success or failure rate
    Import wizard completed and you have the data!
    bcp utility
    Method two is bcp with a format file http://msdn.microsoft.com/en-us/library/ms162802.aspx
    This is probably going to win for speed on most occasions but is limited to the formatting of the file being imported.  For this file it actually works well with a small format file to show the contents and mappings to SQL Server.
    To create a format file all we really need is the type and the count of columns for the most basic files.  In our case the qualifier makes it a bit difficult but there is a trick to ignoring them.  The trick is to basically throw a field into the
    format file that will reference it but basically ignore it in the import process.
    Given that our format file in this case would appear like this
    9.0
    9
    1 SQLCHAR 0 0 """ 0 dummy1 ""
    2 SQLCHAR 0 50 "","" 1 Field1 ""
    3 SQLCHAR 0 50 "","" 2 Field2 ""
    4 SQLCHAR 0 50 "","" 3 Field3 ""
    5 SQLCHAR 0 50 ""," 4 Field4 ""
    6 SQLCHAR 0 50 "," 5 Field5 ""
    7 SQLCHAR 0 50 "," 6 Field6 ""
    8 SQLCHAR 0 50 "," 7 Field7 ""
    9 SQLCHAR 0 50 "n" 8 Field8 ""
    The bcp call would be as follows
    C:Program FilesMicrosoft SQL Server90ToolsBinn>bcp DBA..zips in “C:zips.txt” -f “c:zip_format_file.txt” -S LKFW0133 -T
    Given a successful run you should see this in command prompt after executing the statement
    Starting copy...
    1000 rows sent to SQL Server. Total sent: 1000
    1000 rows sent to SQL Server. Total sent: 2000
    1000 rows sent to SQL Server. Total sent: 3000
    1000 rows sent to SQL Server. Total sent: 4000
    1000 rows sent to SQL Server. Total sent: 5000
    1000 rows sent to SQL Server. Total sent: 6000
    1000 rows sent to SQL Server. Total sent: 7000
    1000 rows sent to SQL Server. Total sent: 8000
    1000 rows sent to SQL Server. Total sent: 9000
    1000 rows sent to SQL Server. Total sent: 10000
    1000 rows sent to SQL Server. Total sent: 11000
    1000 rows sent to SQL Server. Total sent: 12000
    1000 rows sent to SQL Server. Total sent: 13000
    1000 rows sent to SQL Server. Total sent: 14000
    1000 rows sent to SQL Server. Total sent: 15000
    1000 rows sent to SQL Server. Total sent: 16000
    1000 rows sent to SQL Server. Total sent: 17000
    1000 rows sent to SQL Server. Total sent: 18000
    1000 rows sent to SQL Server. Total sent: 19000
    1000 rows sent to SQL Server. Total sent: 20000
    1000 rows sent to SQL Server. Total sent: 21000
    1000 rows sent to SQL Server. Total sent: 22000
    1000 rows sent to SQL Server. Total sent: 23000
    1000 rows sent to SQL Server. Total sent: 24000
    1000 rows sent to SQL Server. Total sent: 25000
    1000 rows sent to SQL Server. Total sent: 26000
    1000 rows sent to SQL Server. Total sent: 27000
    1000 rows sent to SQL Server. Total sent: 28000
    1000 rows sent to SQL Server. Total sent: 29000
    bcp import completed!
    BULK INSERT
    Next, we have BULK INSERT given the same format file from bcp
    CREATE TABLE zips (
    Col1 nvarchar(50),
    Col2 nvarchar(50),
    Col3 nvarchar(50),
    Col4 nvarchar(50),
    Col5 nvarchar(50),
    Col6 nvarchar(50),
    Col7 nvarchar(50),
    Col8 nvarchar(50)
    GO
    INSERT INTO zips
    SELECT *
    FROM OPENROWSET(BULK 'C:Documents and SettingstkruegerMy Documentsblogcenzuszipcodeszips.txt',
    FORMATFILE='C:Documents and SettingstkruegerMy Documentsblogzip_format_file.txt'
    ) as t1 ;
    GO
    That was simple enough given the work on the format file that we already did.  Bulk insert isn’t as fast as bcp but gives you some freedom from within TSQL and SSMS to add functionality to the import.
    SSIS
    Next is my favorite playground in SSIS
    We can do many methods in SSIS to get data from point A, to point B.  I’ll show you data flow task and the SSIS version of BULK INSERT
    First create a new integrated services project.
    Create a new flat file connection by right clicking the connection managers area.  This will be used in both methods
    Bulk insert
    You can use format file here as well which is beneficial to moving methods around.  This essentially is calling the same processes with format file usage.  Drag over a bulk insert task and double click it to go into the editor.
    Fill in the information starting with connection.  This will populate much as the wizard did.
    Example of format file usage
    Or specify your own details
    Execute this and again, we have some data
    Data Flow method
    Bring over a data flow task and double click it to go into the data flow tab.
    Bring over a flat file source and SQL Server destination.  Edit the flat file source to use the connection manager “The file” we already created.  Connect the two once they are there
    Double click the SQL Server Destination task to open the editor.  Enter in the connection manager information and select the table to import into.
    Go into the mappings and connect the dots per say
    Typical issue of type conversions is Unicode to non-unicode.
    We fix this with a Data conversion or explicit conversion in the editor.  Data conversion tasks are usually the route I take.  Drag over a data conversation task and place it between the connection from the flat file source to the SQL Server destination.
    New look in the mappings
    And after execution…
    SqlBulkCopy Method
    Sense we’re in the SSIS package we can use that awesome “script task” to show SlqBulkCopy.  Not only fast but also handy for those really “unique” file formats we receive so often
    Bring over a script task into the control flow
    Double click the task and go to the script page.  Click the Design script to open up the code behind
    Ref.
    Ahsan Kabir Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. http://www.aktechforum.blogspot.com/

  • Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft SQL Server)

    I am getting the error message, "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. (Microsoft SQL Server)". I am attaching the stored procedure. Can anyone see where the syntax may
    be causing this.
    USE [ReportData]
    GO
    /****** Object: StoredProcedure [PDI].[usp_MJTestTop10_Select] Script Date: 04/23/2015 10:35:43 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    --USE [ReportData]
    --GO
    --/****** Object: StoredProcedure [PDI].[usp_MJTestTop10_Select] Script Date: 04/23/2015 08:22:26 ******/
    --SET ANSI_NULLS ON
    --GO
    --SET QUOTED_IDENTIFIER ON
    --GO
    ALTER PROCEDURE [PDI].[usp_MJTestTop10_Select]
    @StartDate DATE,
    @EndDate DATE,
    @Location VARCHAR
    AS
    DECLARE @CalendarKey TABLE (
    Calendar_Key int,
    Organization_Key int,
    Day_Date DATETIME
    BEGIN
    INSERT INTO @CalendarKey
    SELECT C.calendar_key,
    O.Organization_Key,
    C.Day_Date AS DATETIME
    FROM pdi.PDI_Warehouse_952_01.dbo.calendar C,
    pdi.PDI_Warehouse_952_01.dbo.Organization O
    where @EndDate is not null
    and C.Day_Date BETWEEN @StartDate and @EndDate
    or @EndDate is null
    and C.Day_Date = @StartDate
    END
    SELECT CAST(C.Day_Date as DATE) as [Memo Date],
    --C.calendar_key,
    ISNULL(CAST(MBH.Transaction_Number as VARCHAR), 'Unknown') as [Memo Number],
    O.Site_id,
    O.Site_desc,
    --p.Product_Key,
    p.UPC as [UPC],
    (CAST(P.Department_ID as VARCHAR) + ' ' + CAST(P.Category_ID as VARCHAR) + ' ' + CAST(P.Sub_Category_Id as VARCHAR)) as [D C S],
    ISNULL(CAST(IPF.Vendor_Key as VARCHAR), 'Unknown') as [Vendor Code],
    --ISNULL(CAST(V.Vendor_Desc as VARCHAR), 'Unknown') as [Vendor Desc],
    ISNULL(P.Item_Desc, 'Unknown') as [Description],
    ISNULL(P.Size_Desc, 'Unknown') as [Size],
    ISNULL(RTrim(Cash.Cashier_Name), 'Unknown') as [Associate],
    ISNULL(CONVERT(INT, IIF.Beg_Inv_Qty, 0), '0') as [Old Qty],
    ISNULL(CONVERT(INT, IIF.End_Inv_Qty,0), '0') as [Adj Qty],
    ISNULL(CONVERT(INT, IIF.End_Inv_Qty - IIF.Beg_Inv_Qty, 0), '0') as [Dif Qty]
    FROM pdi.PDI_Warehouse_952_01.dbo.Item_Sales_Fact ISF
    INNER JOIN pdi.PDI_Warehouse_952_01.dbo.Product P ON ISF.Product_Key = P.Product_Key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Organization O ON ISF.Organization_key = O.organization_key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Item_Purchases_Fact IPF ON ISF.Product_key = IPF.Product_Key
    AND ISF.Organization_key = IPF.Organization_key
    AND ISF.Calendar_key = IPF.Calendar_key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Item_Inventory_Fact IIF ON ISF.Product_Key = IIF.Product_Key
    AND IIF.Product_Key = P.Product_Key
    AND ISF.Organization_key = IIF.Organization_Key
    AND ISF.Calendar_key = IIF.Calendar_Key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Calendar C ON ISF.calendar_key = C.calendar_key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Cashier Cash ON ISF.Organization_Key = Cash.Organization_Key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Cashier_Metric_Hourly_Dept_Snapshot CMH on Cash.Organization_Key = CMH.Organization_Key
    AND Cash.Cashier_Key = CMH.Cashier_Key
    AND ISF.Calendar_Key = CMH.Calendar_Key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.MarketBasket_Header MBH ON ISF.Calendar_Key = MBH.Calendar_Key
    AND ISF.Organization_Key = MBH.Organization_Key
    AND Cash.Cashier_Key = MBH.Cashier_Key
    LEFT JOIN pdi.PDI_Warehouse_952_01.dbo.Vendor V ON IPF.Vendor_Key = V.Vendor_key
    AND IPF.Calendar_Key = C.Calendar_Key
    LEFT JOIN @CalendarKey CK ON ISF.Calendar_Key = ck.Calendar_Key
    AND ISF.Organization_Key = CK.Organization_Key
    WHERE C.calendar_key = CK.Calendar_Key
    ORDER BY
    O.Location_ID,
    C.Day_Date,
    IPF.Vendor_Key,
    P.UPC,
    P.Size_Desc

    Some additional comments. 
    @Location VARCHAR
    Look closely at this.  How many characters can @Location contain?  You did not specify, so perhaps you think some appropriately large default value is used.  Guess again. You did a similar thing with cast (multiple times) - which is handled
    differently.  Don't be lazy.
    WHERE C.calendar_key = CK.Calendar_Key
    Go review the join to the CK table.  It is an outer join.  Yet you have included criteria in the where clause that requires a match in the unpreserved (@CalendarKey aka CK) table.  This effectively transforms that join from outer to inner.
    Was that intentional? Probably, but then you don't need to use an outer join
    FROM pdi.PDI_Warehouse_952_01.dbo.calendar C,
    pdi.PDI_Warehouse_952_01.dbo.Organization O
    Evolve.  We do not join in the where clause any longer.  You should be joining using join operators.  And perhaps more importantly, why do you need to dump a resultset into a table variable at all?  Note that your join is a cross join
    since there is no relationship between calendar and Organization - intentional? Given the rest of the logic, it seems that you don't really need to do this.
    ISNULL(CONVERT(INT, IIF.End_Inv_Qty,0), '0') as [Adj Qty],
    Go review the documentation for convert.  You supply a style, but does it do anything?  We don't know what datatype End_Inv_Qty is, but I assume it is numeric (and not float).  So what do you intend?  And you convert it to integer but
    use a character '0' in the isnull function.  Your lack of consistency can lead to issues that are difficult to find and resolve.
    CAST(C.Day_Date as DATE)
    Why are you doing this? You defined the column in your table variable as datetime.  You cast the value you use to populate this column to datetime.  I'm guessing that you only really care about the date portion.  The name you used for the
    column implies this.  So why bother with datetime in the first place?
    And one last suggestion. If you disallow the use of NULL for the @EndDate argument (simply supply the same value for both date arguments) you can simplify the logic that populates your table variable (or its replacement) and greatly eliminate the confusion
    and chance for errors that nullability requires.

  • Setting up Microsoft SQL Server datasource in Websphere 4.0

    Does anyone know how to setup an SQL Server jdbc driver in Websphere 4.0? I am using jdbc driver from jTurbo. But I am having trouble specifying the proper URL and other datasource settings in Websphere 4.0 (or WTE) server configuration.

    Hi,
    Please find the extract from jTurbo site (http://www.newatlanta.com/support/jturbo/third-party.jsp#WebSphere)
    which will explain the steps to follow for setting up Microsoft SQL Server datasource
    in Websphere 4.0 using jTurbo jdbc driver.
    1.Always make sure the JTurbo.jar is set in your classpath.
    2.Started "WebSphere Admin Server"
    3.Open "WebSphere Administrative Console"
    4.Install the JTurbo Driver into WAS by modifying the following field of "Admin DB Driver"
    Name: JTurbo
    Class Name: com.ashna.jturbo.driver.Driver
    URL prefix: jdbc:JTurbo://localhost/pubs
    JTA Enabled: false
    (apply changes which resulted in the installation of JTurbo Driver)
    5.Selected "Create Data Source" in Console "Wizards" drop down
    6.Selected "Use an already installed JDBC Driver" JDBC Option
    7.Specified "my ds name" as the "Data Source Name"
    Specified "pubs" as the "Database Name" pull down is showing "JTurbo"
    This should sucessfully create a new data source by the name of "my ds name".
    Also there is an excellent document on "Configuring the Merant ConnectJDBC data source for MS SQL Server for the WebSphere Application Server Advanced Single Server Edition" at http://www-4.ibm.com/software/webservers/appserv/doc/v40/ae/infocenter/was/was402/rn112253.4.html .
    Hope this helps. Good luck.
    Best Regards
    Gayam_Slash

  • Reports & Microsoft SQL Server 2012 Express LocalDB support policy

    Hello,
    Willing to move some databases into Microsoft SQL Server 2012 (2014) Express LocalDB, I have tryed to map some reports on that database.
    Using OLE DB SQL Native Client (v11) and SAP CR RunTime SP10 (>SP9), I still have trouble when using this data source:
    After drawing some simple reports (standard ones with 2-3 fields from the database):
    - VS designer:
    + when "checking database" or "getting a preview" of the report, it always complains about missing tables.
    + when trying to "re-map" tables from one SQL Server 2012 Express LocalDB to another one it fails, complaining about not findind resources.
    - Running application (.NET 4.0, 32 or 64-bits):
    + without any change to the report configuration: CR Viewer complains with multiple error codes (17, ...) that it cannot find the tables
    + trying to change the configured database from the report: CR VIewer complains with some more error codes
    => Is Microsoft SQL Server 2012 Express LocalDB now officially supported by CR ?
    => Is changing datasource/database configuraton during execution now officially supported by CR ?
    Feel free to provide an any links / howto's / white paper about how managing Microsoft SQL Server 2012 Express LocalDB with SAP CR !
    Many thanks in advance.
    Regards.

    Don,
    I did not want you to think that I am not willing to change anything...
    The issue is that LocalDB specs (http://msdn.microsoft.com/en-us/library/ms130822(v=sql.110).aspx) are not (seems not) fulfiled by what SAP APIs provide.
    Following specs, I need to provide ADO DB/SQL Native Client v11 an "AttachDBFileName" property which, for LocalDB instance, is equal to the DatabaseName property (check below screenshot from MS Mgmt Studio connected to a SQL Server 2012 LocalDB instance).
    Moreover, OLEDB discovery provide in CR 2013 UI this same list of "DatabaseName":
    When connected, this same CR 2013 UI got the right "view" of connected "MDF-labelled" names:
    Moreover, CR connected datasource properties also provide an "initial catalog" (databasename) value with that "MDF-labelled" name:
    That is what I saw previously in API dumped objects and what I tryed to reproduce in my code:
    As previously explained, after adding tables, I am also beeing able to add fields from those tables in my fresh-new report document:
    It fikrst shows results in preview but as soon as I try to refresh / add some more fields / ask CR to "check database" / "change database source", the interface always complain about having "lost" objects:
    Site note for Ludek Uher: CR 2013 StandaAlone fresh-new builded reports are not working neither using CR runtime SP10 when opening/updating that report..
    So YES, I am OK to change whatever is required but please explain me what to use/put into the "crConnectioninfo.DatabaseName" property for a SQL Express 2012 LocalDB case.
    Or leave it as is, LocalDB not being supported by CR ...
    (all my reports & c# code are working well while using SQL Express 2012 "classic" (not localdb)).
    Thanks again for your time.
    Regards.

  • Create a table in SQL Server, Export tables from Microsoft Excel to Microsoft SQL Server, Populate the created table

    Hello team,
    I have a project that I need to do, what is the best approach for each step?
    1- I have to create a table in Microsoft SQL Server.
    2- I have to import data/ tables from Microsoft Excel or Access to Microsoft SQL Server. Should I use Microsoft Visual Studio to move data from Excel or Access?
    3-I should populate the created table with the data from the exported data.
    4-How should I add the second and third imported table to the first table? Should I use union query?
    After I learn these, I will bring up the code to make sure what I do is right.
    Thanks for all,
    Guity
    GGGGGNNNNN

    Hello Naomi,
    I have imported all the tables into SQL Server,
    I created a table:
    CREATE
    TABLE dbo.Orders
    Now I want to populate this table with the values from imported tables, will this code take care of this task?
    INSERT INTO dbo.Orders(OrderId, OrderDate)
    SELECT OrderId, OrderDate
    FROM Sales.Orders
    UNION
    SELECT OrderId, OrderDate
    FROM Sales.Orders1
    Union
    SELECT OrderId, OrderDate
    FROM Sales.Orders2
    If not, what is the code?
    Please advise me.
    GGGGGNNNNN
    GGGGGNNNNN

  • 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

Maybe you are looking for