Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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. …
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

671 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