JOIN dimProduct p ON s.ProductKey = p.ProductKey Pc.EnglishProductCategoryName as ,Ĭ.LastName as, c.FirstName as, c.AddressLine1 as ,Ĭg., cg.StateProvinceName as, cg.EnglishCountryRegionName as SET = - 2008R2 and below use DATEADD(d, -1, DATEADD(M, 1, as, SUM(s.SalesAmount) as sales, Declare datetime = '', nvarchar(50) = 'Bikes' What an easy way to distinguish yourself from your peers! Personal Rant: Hey looky here! Meaningful code comments!!! Source of data for the Excel report 'Sales by Category by - The month will always be passed as - Hard-coded Category name IF EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'xrpt_sales_by_category_by_month')ĭROP PROCEDURE xrpt_sales_by_category_by_monthĬREATE PROC xrpt_sales_by_category_by_month as date, as nvarchar(50)) AS Notice the use of aliases with spaces that force the use of, which is not normally a best practice, but this way the column names that will appear in Excel.Ĭopy-paste the below code into an open SSMS window connected to the server that contains your copy of AdventureWorks2012DW, and execute. which is the table DimProductCategory, column EnglishProductCategoryName.- datetime, which is the first day of any given month, e.g.It started with just the SELECT statement, and then I added the two parameters whose values will be passed from Excel. Excel VBA to make the Stored Procedure execute with user-entered valuesġ Create a SQL Server Stored Procedure Below is a pretty basic query I coded to return Internet Sales in the AdventureWorks 2012 Data Warehouse.Excel connects and executes the SQL Server Stored Procedure.Logging: How to stalk your users for fun and self-promotion.Connections other than SQL Server, such as Oracle, Informix, DB2..
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |