Use WSH to receive messages on the Windows desktop

Source: Internet
Author: User
Tags sql server query
The company's sales managers daily want to receive orders in $10,000 yuan above the email, but also very willing to thank the letter to order users. The body of an e-mail message includes all the necessary information, so there is no need to access the corporate client/server program. The first step is to delegate data to the database server near-possible. In this example, I chose the Northwind database that came with SQL Server 7.0 installation.
Original source: http://www.15seconds.com/issue/991007.htm
I decided to create a view in the Northwind database that would provide everything you need. Start the SQL Server Enterprise Manager, check the list of views under the Northwind database, and the Order subtotals view is in front of you, which calculates the sum of all the orders placed in the Northwind database. I decided to refer to this view in the new view 10k_order_qry, as follows:
CREATE VIEW dbo. [10k_order_qry]
As
SELECT [Order Subtotals]. OrderID, CONVERT (varchar (15),
[Order subtotals]. Subtotal) as ' Subtotal ', CONVERT (char (10),
Orders.orderdate,) as ' OrderDate ',
Customers.companyname, Customers.contactname,
Customers.country, Customers.phone
From [Order subtotals], Orders, Customers
WHERE [Order Subtotals]. OrderID = Orders.OrderID and
Orders.CustomerID = Customers.CustomerID and
Subtotal >= 10000
--Below lines can be switched in the order of "for today's" sales over $10,000
--(Comment the next line, and uncomment the second line)
and OrderDate >= ' 02-01-1998 ' and OrderDate <= ' 02-28-1998 '
--and OrderDate = convert (char (), GETDATE (), 110)
Note: Referencing another view in a view is not a good way to do it. However, this is not discussed in detail here.
To not modify the data in the Northwind and display it in the message, review the last 2 lines of the new View "10k_order_qry". The comment line on it explains the final purpose. I would like to emphasize that writing a stored procedure can achieve better performance because the stored procedure can be compiled. Setting up an execution plan for SQL Server will drastically reduce the effort in planning execution.
To verify that all the fields required for the output report are ready, we can perform this view in SQL Server Query Analyzer for testing.
Most of us, in quite a few cases, have used scripts in MS-DOS batch files. Microsoft Windows Scripting Host, which is integrated into Windows 98, Internet Information Server 4.0, Windows NT Workstation 2000, and Windows NT Server 2000, is A scripting engine for an independent language. Visual Basic and JavaScript scripting engines are also included in the Windows Scripting Host.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.