Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Sql Server Programming

Stored Procedure querying for a particular year


I have written the stored procedure below. My intention is to execute the SP
and only get information for the year 2000. I ran the query separately so I
know there is data for 2000 but I get a blank when I add the year.

use bellpeek
IF Object_ID('spCombineCustData7') IS NOT NULL
        DROP Proc spCombineCustData7
go
create proc spCombineCustData7
        @ProductName varchar(35)=NULL,
        @Region varchar(35)=NULL,
        @Year datetime=NULL
as
SELECT R.RegionName,C.CustomerName,P.ProductName,SUM(OI.Qty) as
Qty,SUM(OI.Qty*OI.Price) as 'Value'
FROM Customers C
        inner join Orders O
        on C.CustomerID=O.CustomerID
        inner join OrderItems OI
        on O.InvoiceID=OI.InvoiceID
        inner join Products P
        on OI.ProductID=P.ProductID
        inner join RegionStates RS
        on C.State=RS.State
        inner join Regions R
        on RS.RegionID=R.RegionID
where P.ProductName=@Productname and R.RegionName=@Region and
year(O.OrderDate)=@Year
Group by R.RegionName,P.ProductName, C.CustomerName

exec spCombineCustData7 'BPWrite','North Central','2000'

On May 30, 10:21 am, RuthE <R@discussions.microsoft.com> wrote:

You have defined  @Year datetime . Define @Year  INT and try
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc