How to create YTD and MTD reports using Sql Server 2008 r2 report builder 3.0

Hi All,
How can I create YTD report from the below data. please help me
ProdA     ProdB     ProdC     Month     Year
10       50        40          January      2012
Data for full Year i.e. from Jan - December 2012
50       90       100        January       2013
Data for full Year i.e. from Jan - December 2013
90       40         30        January        2014
Data for full Year i.e. from Jan - Till Date 2014
MercuryMan

You can use a correlated subquery to calculate YTD in query behind. You can use APPLY operator for that
so something like
SELECT *
FROM Table t1
CROSS APPLY (SELECT SUM(ProdA) AS TotA,SM(prodB) AS TotB,SUM(prodC) AS TotC
FROM Table
WHERE Year = t.Year)t1
And show TotA,TotB and TotC in the required total row
Another method is to add required totals in SSRS by clicking on relevant group and choosing Add Total option
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

Similar Messages

  • How to create a composite nonclustered index using sql server management studio

    Hi,
    How do I create a composite non clustered index using Manage Index and Keys dialogue box?
    sukai

    See image below:
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • XML errors when running specific reports in SCCM 2012, using SQL Server 2008 R2 Reporting Services

    I've posted this to the SCCM 2012 forum and only received one response so far that states that this is a known issue that has been discussed before and isn't easy to fix;  I was not given any actual solution either.  Since this involves SSRS I
    thought I would try my luck here as well.  
    I'm having almost exactly the same problem as is referenced in this article:  http://social.msdn.microsoft.com/Forums/uk/sqlreportingservices/thread/587a3319-bc54-4d30-bb3f-bb90a0c6ec50.  When
    I try to run either of these reports (Computers with specific software registered in Add Remove Programs; Count of instances of specific software registered with Add or Remove Programs) I receive the XML error shown in the attached screenshot.  I'm fairly
    sure the problem is the same as the other admin was experiencing and I just need to remove the unprintable characters (of the application name) from the dbo.v_Add_Remove_Program column.    
    The error references 0xFFFF but I could not find what that exactly translates too, other than it appears to be at the end of the spectrum for Unicode characters.  I used the following sql query to search for the 0xFFFF entry, but no results were found:
    use CM_UV2
    Select distinct
     CHARINDEX(cast(0xFFFF as varchar(1)),DisplayName0),
     DisplayName0
    from
     dbo.v_Add_Remove_Programs
    Where
     CHARINDEX(cast(0xFFFF as varchar(1)),DisplayName0) > 0
    When I used the original hex value of 0x28 I get plenty of results returned with "(" in them so the query seems sound.  One of the articles I was searching mentioned running the query manually using the Management Studio and looking for strange characters
    there but I'm not sure how to do that. 
    Basically I just need help finding the offending character and removing it.  I also need to be able to replicate this for other strings as this looks like an error that will reoccur whenever any new software appears that has weird encoding in the title. 
    Thank you in advance for any help given.
    Über Random

    Hi Uber,
    This is a known issue that error occurs when running report "Count of instances of specific software registered with Add or Remove Programs" due to non-printable characters for XML. Based on internal research, the hotfix for this issue will be
    included in the System Center 2012 Configuration Manager Service Pack 1.
    As a workaround, you can remove the nonprintable character populated into the report parameter by referring to the following KB article:
    http://support.microsoft.com/KB/914159
    Hope this helps.
    Regards,
    Mike Yin
    Mike Yin
    TechNet Community Support

  • How to create Profit and loss account using report painter

    Dear All,
    Can some one guide me as to how to create Profit and loss account using report painter.
    If some one can share the document having steps to be done,would be of great help.
    Thanks in advance.
    Regards,
    Gokul

    Hi,
    Could you please re-phrase your question? As the report painter is a reporting tool I assume you want to report on P&L accounts and not u201Ccreateu201D them. A few more details on what you intend to report would be useful.
    Regards
    Karl

  • SAP Crystal Report using SQL Server Authentication and Windows Authenticati

    I'm a SAP Crystal Report, version for Visual Studio 2010 Beginner
    my ingredients are
    1.windows 7 ultimate service pack1
    2.sql server 2008 standard edition
    3.visual studio 2010 pro
    4.SAP Crystal Report, version for visual studio.net
    I was created a report named customersByCity.rpt using OLE DB (ADO) -> Microsoft OLE DB Provider for SQL Server -> I'm supply Server, User ID, Password and Database. I assume me using SQL Server Authentication for my report
    Then, my ASP.NET files as following
    //ASP.NET
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="viewCustomersByCity.aspx.cs" Inherits="viewCustomersByCity" %>
    <%@ Register Assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"
        Namespace="CrystalDecisions.Web" TagPrefix="CR" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div><asp:Label ID="lblMsg" runat="server" BackColor="Yellow" ForeColor="Black"></asp:Label>
     <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server" AutoDataBind="true"></CR:CrystalReportViewer>
        </div>
        </form>
    </body>
    </html>
    //code-behind
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections;
    using CrystalDecisions.CrystalReports.Engine;
    using CrystalDecisions.Shared;
    public partial class viewCustomersByCity : System.Web.UI.Page
        private const string PARAMETER_FIELD_NAME = "city";   
        private ReportDocument customersByCityReport;
        private void ConfigureCrystalReports()
            ConnectionInfo connectionInfo = new ConnectionInfo();
            connectionInfo.ServerName = @"WKM1925-PCWKM1925";
            connectionInfo.DatabaseName = "Northwind";
            connectionInfo.UserID = "sa";
            connectionInfo.Password = "sysadmin25";
            SetDBLogonForReport(connectionInfo);
        private void SetDBLogonForReport(ConnectionInfo connectionInfo)
            TableLogOnInfos tableLogOnInfos = CrystalReportViewer1.LogOnInfo;
            foreach (TableLogOnInfo tableLogOnInfo in tableLogOnInfos)
                tableLogOnInfo.ConnectionInfo = connectionInfo;
        private void SetCurrentValuesForParameterField(ReportDocument reportDocument, ArrayList arrayList)
            ParameterValues currentParameterValues = new ParameterValues();
            foreach (object submittedValue in arrayList)
                ParameterDiscreteValue parameterDiscreteValue = new ParameterDiscreteValue();
                parameterDiscreteValue.Value = submittedValue.ToString();
                currentParameterValues.Add(parameterDiscreteValue);
            ParameterFieldDefinitions parameterFieldDefinitions = reportDocument.DataDefinition.ParameterFields;
            ParameterFieldDefinition parameterFieldDefinition = parameterFieldDefinitions[PARAMETER_FIELD_NAME];
            parameterFieldDefinition.ApplyCurrentValues(currentParameterValues);
        protected void Page_Load(object sender, EventArgs e)
            customersByCityReport = new ReportDocument();
            string reportPath = Server.MapPath("customersByCity.rpt");
            customersByCityReport.Load(reportPath);
            ConfigureCrystalReports();
            ArrayList arrayList = new ArrayList();
            arrayList.Add("paris");
            arrayList.Add("Madrid");
            arrayList.Add("Marseille");
            arrayList.Add("Buenos Aires");
            arrayList.Add("Sao Paulo");
            ParameterFields parameterFields = CrystalReportViewer1.ParameterFieldInfo;
            SetCurrentValuesForParameterField(customersByCityReport, arrayList);
            CrystalReportViewer1.ReportSource = customersByCityReport;
    1st scenario
    When in a runtime, it's keep appear a dialog box. This dialog box ask me to suppy Server, User ID, Password and Database. Once all information is supplied, my report display the data as expected
    2nd scenario
    I change my report using OLE DB (ADO) -> Microsoft OLE DB Provider for SQL Server -> checked on Integrated Security. I just choose Server, and Database. I assume me using Windows Authentication
    When in a runtime, there's no dialog box as above. My report display the data as expected. really cool
    Look's like, when report using SQL Server Authentication there's some problem. but, when report using Windows Authentication, it's fine.
    I'm looking for comment. Please help me

    Hello,
    MS SQL Server 2008 requires you to install the MS Client Tools for 2008.
    Once install then update all of your reports to use the SQL Native 10 as the OLE DB driver.
    The try again, if it still fails search, lots of sample log on code in this forum.
    Don

  • How to Custom Report using sql server report builder for SCCM 2012 SP1

    Hi ,
    I am new to database, if i want to create a manual report using sql server report builder for SCCM 2012 SP1, what step should i take.
    i want to create a report in which computer name, total disk space, physical disk serial no come together. i already added class (physical disk serial no.) in hardware inventory classes. refer snapshot

    Hi,
    Here is a guide on how to create custom reports in Configuration Manager 2012, it is a great place to start, change to the data you want to display instead.
    http://sccmgeekdiary.wordpress.com/2012/10/29/sccm-2012-reporting-for-dummies-creating-your-own-ssrs-reports/
    Regards,
    Jörgen
    -- My System Center blog ccmexec.com -- Twitter
    @ccmexec

  • How to find a record then edit using sql server management studio

    Hello,
    A very basic question:
    I want to find a record stored in MS SQL Server 2008 express database table then edit the record.
    I tried to do it using SQL Server 2008 management studio express because I have been using MS Access database all the time. I have right clicked the table in management studio, clicked the "Edit top 200 records" menu item then when records were
    displayed on the result pane, I pressed Ctrl + F key to find a student named Simon for example. Well, nothing happened. I couldn't see any dialog boxes for putting in the search criteria.
    I guess I cannot simply use Ctrl+F in SQL Server management studio to find / edit a record.
    Can someone please teach me how to find a record specifying a search criteria then edit the record in SQL server management studio?

    Hi ZKM128,
    I have not seen Ctrl+F to be used to look for desired rows in Sql server.
    On the result pane after you selected "Edit top 200 records", just right click , select
    PANE, SQL, you will get the T-Sql query t,here you need to mention the exact criteria which you are looking for, and then you will get the desired rows and then you can edit.
    Thanks
    Manish
    Please use Marked as Answer if my post solved your problem and use
    Vote As Helpful if a post was useful.

  • How to create database link from oracle to sql server

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal

    Please help with how to create database link from oracle to sql server
    Best regards,
    Vishal
    Hi Vishal,
    I found a lof of information regarding how to create a database link from Oracle to SQL Server, please see:
    https://www.google.co.in/?gws_rd=cr&ei=vd3XUvGFO8TgkAXqlYCADg#q=how+to+create+database+link+from+oracle+to+sql+server
    We discuss SQL Server related issue in this forum. If you have any more question regarding Oracle, please post it in Oracle communities forum for better support.
    Regards,
    Elvis Long
    TechNet Community Support

  • Improve the performance in stored procedure using sql server 2008 - esp where clause in very big table - Urgent

    Hi,
    I am looking for inputs in tuning stored procedure using sql server 2008. l am new to performance tuning in sql,plsql and oracle. currently facing issue in stored procedure - need to increase the performance by code optmization/filtering the records using where clause in larger table., the requirement is Stored procedure generate Audit Report which is accessed by approx. 10 Admin Users typically 2-3 times a day by each Admin users.
    It has got CTE ( common table expression ) which is referred 2  time within SP. This CTE is very big and fetches records from several tables without where clause. This causes several records to be fetched from DB and then needed processing. This stored procedure is running in pre prod server which has 6gb of memory and built on virtual server and the same proc ran good in prod server which has 64gb of ram with physical server (40sec). and the execution time in pre prod is 1min 9seconds which needs to be reduced upto 10secs or so will be the solution. and also the exec time differs from time to time. sometimes it is 50sec and sometimes 1min 9seconds..
    Pl provide what is the best option/practise to use where clause to filter the records and tool to be used to tune the procedure like execution plan, sql profiler?? I am using toad for sqlserver 5.7. Here I see execution plan tab available while running the SP. but when i run it throws an error. Pl help and provide inputs.
    Thanks,
    Viji

    You've asked a SQL Server question in an Oracle forum.  I'm expecting that this will get locked momentarily when a moderator drops by.
    Microsoft has its own forums for SQL Server, you'll have more luck over there.  When you do go there, however, you'll almost certainly get more help if you can pare down the problem (or at least better explain what your code is doing).  Very few people want to read hundreds of lines of code, guess what's it's supposed to do, guess what is slow, and then guess at how to improve things.  Posting query plans, the results of profiling, cutting out any code that is unnecessary to the performance problem, etc. will get you much better answers.
    Justin

  • How to export data with column headers in sql server 2008 with bcp command?

    Hi all,
    I want know "how to export data with column headers in sql server 2008 with bcp command", I know how to import data with import and export wizard. when i
    am trying to import data with bcp command data has been copied but column names are not came.
    I am using the below query:-
    EXEC master..xp_cmdshell
    'BCP "SELECT  * FROM   [tempdb].[dbo].[VBAS_ErrorLog] " QUERYOUT "D:\Temp\SQLServer.log" -c -t , -T -S SERVER-A'
    Thanks,
    SAAD.

    Hi All,
    I have done as per your suggestion but here i have face the below problem, in print statment it give correct query, in EXEC ( EXEC master..xp_cmdshell @BCPCMD) it was displayed error message like below
    DECLARE @BCPCMD
    nvarchar(4000)
    DECLARE @BCPCMD1
    nvarchar(4000)
    DECLARE @BCPCMD2
    nvarchar(4000)
    DECLARE @SQLEXPRESS
    varchar(50)
    DECLARE @filepath
    nvarchar(150),@SQLServer
    varchar(50)
    SET @filepath
    = N'"D:\Temp\LDH_SQLErrorlog_'+CAST(YEAR(GETDATE())
    as varchar(4))
    +RIGHT('00'+CAST(MONTH(GETDATE())
    as varchar(2)),2)
    +RIGHT('00'+CAST(DAY(GETDATE())
    as varchar(2)),2)+'.log" '
    Set @SQLServer
    =(SELECT
    @@SERVERNAME)
    SELECT @BCPCMD1
    = '''BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT '
    SELECT @BCPCMD2
    = '-c -t , -T -S '
    + @SQLServer + 
    SET @BCPCMD
    = @BCPCMD1+ @filepath 
    + @BCPCMD2
    Print @BCPCMD
    -- Print out below
    'BCP "SELECT 
    * FROM   [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername'
    EXEC
    master..xp_cmdshell
    @BCPCMD
      ''BCP' is not recognized as an internal or external command,
    operable program or batch file.
    NULL
    if i copy the print ourt put like below and excecute the CMD it was working fine, could you please suggest me what is the problem in above query.
    EXEC
    master..xp_cmdshell
    'BCP "SELECT  * FROM  
    [tempdb].[dbo].[wErrorLog] " QUERYOUT "D:\Temp\LDH_SQLErrorlog_20130313.log" -c -t , -T -S servername '
    Thanks, SAAD.

  • How to point out high CPU Utilization in sql server 2008

    Hi,
    I am using sql server 2008 , where in i have 10 instances in the physical box of all sql server 2008 versions.
    I can see , the CPU (12 CPUS) that is allocated to the physical box is consuming around 90% of utilization, I need your help to point out the exact sql instance that is using more CPU, Please give me the mathods , since i understand that there is no fixed
    rule to derive the solution.
    Thank you
    hemadri

    This first thing to check if CPU is at 100% is to look for parallel queries:
    -- Tasks running in parallel (filtering out MARS requests below):
    select * from sys.dm_os_tasks as t
     where t.session_id in (
       select t1.session_id
        from sys.dm_os_tasks as t1
       group by t1.session_id
      having count(*) > 1
      and min(t1.request_id) = max(t1.request_id));
    -- Requests running in parallel:
     select *
       from sys.dm_exec_requests as r
       join (
               select t1.session_id, min(t1.request_id)
              from sys.dm_os_tasks as t1
             group by t1.session_id
            having count(*) > 1
               and min(t1.request_id) = max(t1.request_id)
          ) as t(session_id, request_id)
         on r.session_id = t.session_id
        and r.request_id = t.request_id;
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • How to repair database using SQL server 2008 and C#

    How to repair database in SQL server 2008 using C#
    Musakkhir Sayyed.

    Unfortunately your post is off topic as it's not specific to SQL Server Samples and Community Projects.  
    This is a standard response I’ve written in advance to help the many people who post their question in this forum in error, but please don’t ignore it.  The links I provide below will help you determine the right forum to ask your
    question in.
    For technical issues with Microsoft products that you would run into as an end user, please visit the Microsoft Answers forum ( http://answers.microsoft.com ) which has sections for Windows, Hotmail,
    Office, IE, and other products.
    For Technical issues with Microsoft products that you might have as an IT professional (like technical installation issues, or other IT issues), please head to the TechNet Discussion forums at http://social.technet.microsoft.com/forums/en-us, and
    search for your product name.
    For issues with products you might have as a Developer (like how to talk to APIs, what version of software do what, or other developer issues), please head to the MSDN discussion forums at http://social.msdn.microsoft.com/forums/en-us, and
    search for your product or issue.
    If you’re asking a question particularly about one of the Microsoft Dynamics products, a great place to start is here: http://community.dynamics.com/
    If you think your issue is related to SQL Server Samples and Community Projects and I've flagged it as Off-topic, I apologise.  Please repost your question and include as much detail as possible about your problem so that someone can assist you further. 
    If you really have no idea where to post your question please visit the Where is the forum for…? forum http://social.msdn.microsoft.com/forums/en-us/whatforum/
    When you see answers and helpful posts, please click Vote As Helpful,
    Propose As Answer, and/or Mark As Answer
    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCSA, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID:
    Microsoft Transcript

  • Windows 8 and IE 10 crashed after printing from Report Manager SQL server 2008 / 2008 R2

    We have a problem with Windows 8 in combination with IE 10 and printing reports.
    When we print a report from the Report Manager 'http://<servername>/reports' the browser crashed after a print.
    Sometimes before printing and somthimes after printing or when you close the browser.
    Al other operating systems like XP, Vista, Windows 7 with different IE versions have no problem.
    I tried the report manager from SQL Server 2008 and SQL Server 2008 R2.
    The same error occured when printing from our Internet application and the reportviewer.
    (ASP application written in Visual Studio 2010 and reportviewer version 10.)
    The event log shows two different messages.
    Faulting application name: IEXPLORE.EXE, version: 10.0.9200.16453, time stamp: 0x509b0dfb
    Faulting module name: ntdll.dll, version: 6.2.9200.16420, time stamp: 0x505aaa82
    Exception code: 0xc0000005
    Fault offset: 0x00061252
    Faulting process id: 0x780
    Faulting application start time: 0x01ce03a294f7d1d5
    Faulting application path: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
    Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
    Report Id: d4a72486-6f96-11e2-be6e-10604b6a74ed
    Faulting package full name:
    Faulting package-relative application ID:
    Faulting application name: IEXPLORE.EXE, version: 10.0.9200.16384, time stamp: 0x50107ee0
    Faulting module name: rsclientprint.dll, version: 2009.100.1600.1, time stamp: 0x4bb67a74
    Exception code: 0xc0000005
    Fault offset: 0x00017e7a
    Faulting process id: 0x9c8
    Faulting application start time: 0x01ce02f35c70ab85
    Faulting application path: C:\Program Files (x86)\Internet Explorer\IEXPLORE.EXE
    Faulting module path: C:\Windows\Downloaded Program Files\rsclientprint.dll
    Report Id: a13fccc6-6ee6-11e2-be67-10604b6a74ed
    Faulting package full name:
    Faulting package-relative application ID:
    Is there a fix for this problem?

    Dear Mike Yin,
    Thank you for your response. Your answer was the
    reason for finding the real problem.
    In december 2010 a SQL Server 2008 fix was the cause. I don't remember exactly the problem, but we changed the RSCLIENTPrint-x86.cab file. But instead to use the version of SQL Server 2008 we used the version of SQL Server 2008
    R2 (10.50.1600.1). This worked until
    Windows 8 (Internet Explorer crashed when printing).
    We fixed this problem by using the RSClientPrint-x86.cab file from SQL server 2008 (10.0.5500.0).
    But we now get the known problem that the
    activeX always must be installed again. 
    The reason for this is that the version of
    the SQL Server (10.0.5512.0) 
    and the rsclientprint.dll (10.0.5500.0) is different. SQL Server is newer (caused
    by a security patch (KB2716436)).
    Do you know when this problem will be resolved
    by Microsoft?
    Work arrounds
    I've also tried to install the RSClientprint.dll
    every time automatically (without user interaction).
    But this will be delayed the printing for more
    than 4 seconds. This
    is very annoying.
    Another workaround is to generate a PDF and print the PDF. But this is also
    a lot slower.
    Uninstall the security patch. but I don't know the security risk.

  • How to send PLAIN text email from sp_send_dbmail using SQL Server 2008 R2?

    I have configured Database Mail in SQL Server 2008 R2 (64) and it sends emails just fine. However the destination is recieving the body of thes message as Base 64 encoding.
    Snippet:
    EXEC msdb..sp_send_dbmail @profile_name='Outmail', @recipients = @recpts, @subject = @subj, @body_format = 'TEXT', @body=@body2;
    As you can see I set @body_format to TEXT, but it still sends Base 64. I need to send plain ASCII text. How can I change this?

    I am having this exact issue too.  I have a trigger that sends an email using a stored procedure.  The dbmail is sending the email using the Exchange 2010 server SMTP.  It does not login so the email is relayed as user = "Anonymous". 
    The SQL dbmail email header is showing the following:
    Content-Type: text/plain; charset="utf-8"
    Content-Transfer-Encoding: base64
    MIME-Version: 1.0
    X-MS-Exchange-Organization-AuthSource: MX01.domain.local
    X-MS-Exchange-Organization-AuthAs: Anonymous
    Here is the header if I send via Outlook profile using the legacy program I am trying to automate using SQL Server 2008R2:
    Content-Type: application/ms-tnef; name="winmail.dat"
    Content-Transfer-Encoding: binary
    MIME-Version: 1.0
    X-MS-Has-Attach:
    X-MS-Exchange-Organization-SCL: -1
    X-MS-TNEF-Correlator: <[email protected]>
    MIME-Version: 1.0
    X-MS-Exchange-Organization-AuthSource: MX01.domain.local
    X-MS-Exchange-Organization-AuthAs: Internal
    X-MS-Exchange-Organization-AuthMechanism: 03
    X-Originating-IP: [192.168.13.66]
    Any help would be greatly appreciated!

  • How to populate image and text field in SQL Server

    I want to populate a table, i.e insert images in a table in SQL Server. I am using Java(JSP/Servlet). Can any one suggest me how to populate the image and text fields in SQL Server...of course, using Java. If possible, could you please give me a piece of code?
    Regards -
    Samit

    Hi,
    Please check the following link for information on inserting images in to sql server database.
    http://www.databasejournal.com/features/mssql/article.php/1475641
    Cheers,
    vidyut

Maybe you are looking for