Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2013-01-25
3
Medium Priority
?
207 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 54

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

916 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