Solved

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

Posted on 2013-01-25
3
200 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
3 Comments
 
LVL 52

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Viewers will learn how the fundamental information of how to create a table.
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…

839 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