Solved

Setting Current Date in Stored Procedure HTML Report Emails Direct from SQL-Server

Posted on 2013-01-25
3
204 Views
Last Modified: 2013-10-07
I'm trying to show the current month in the following portion of code N'<caption>Monthy Revenue</caption> , I am not sure how to go about doing this as I am not familiar with HTML coding. I know how to obtain the current month through SQL
select datename(mm,getdate()) but how do I put that into the caption.

Below is the stored procedure

/****
Attribute:
http://www.wikihow.com/Send-a-Scheduled-HTML-Report-Directly-from-SQL-Server
SQL for Current Month select datename(mm,getdate())
****/


USE <database>
go

/****
DROP proc dbo.GetCurrentMonthyRevenue
GO
****/

create procedure dbo.GetCurrentMonthyRevenue
as
begin declare @query nvarchar(max)

set @query =
      N'<h1>Current Month Revenue</h1>' +
      N'<style type=''text/css''>'+
      N'table { border-collapse:collapse; border:1px solid #3399FF; font:10pt verdana; color:#343434; }'+
      N'table td, table th, table caption { border:1px solid #3399FF; }' +
      N'table caption { font-weight:bold; background-color:white; }'+
      N'</style>'+
      
      N'<table>' +
      N'<caption>Monthy Revenue</caption>' +
      N'<tr><th> Location </th><th> Revenue (Shipped) </th><th> Backlog (To Ship) </th><th> Total Est. Revenue
 </th></tr>' +
cast (
      (SELECT
                  td = LOCATION,'',
                  td = [REVENUE (Shipped)],'',
                  td = [BACKLOG (To Ship)],'',
                  td = [TOTAL EST. REVENUE],''
      FROM <database>.dbo.VE_BBB_Order_Summary_MTD_BYTotal
            ORDER BY [ORDER]
            for xml path ('tr'), type) as nvarchar(max)) +
            N'</table>'
select @query
end
go
0
Comment
Question by:TPBasintek
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 38821437
Are you saying you want the current date here, "  N'<caption>Monthy Revenue</caption>' +"

as in   N'<caption>Monthy Revenue January</caption>' +


HTML does not produce the current date.  You would have to either place the date in via your sql meaning once saved, it will be static or use serverside code or javascript.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39552311
I've requested that this question be deleted for the following reason:

Not enough information to confirm an answer.
0

Featured Post

Are You Using the Best Web Development Editor?

The worlds of web hosting and web development are constantly evolving. Every year we see design trends change, coding standards adapt and new frameworks/CMS created. With such a quick pace of change it’s easy to get lost trying to keep up.

See if your editor made the list.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question