Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SQL syntax - Help

Hello!

I am stucked with this problem. I just cant's get this to work. I am trying create a stored procedure to produce a list of products using 3 parameters from 3 different tables.

CREATE PROCEDURE sp_product_listing

(@vproduct varchar(40),

@vmonth datetime=June,

@vyear datetime=2001)

as

SELECT 'product_name'=products.name, products.unit_price,

products.quantity_in_stock, 'supplier_name'=suppliers.name

FROM products

Inner Join suppliers ON products.supplier_id=suppliers.supplier_id

inner join order_details ON products.product_id=order_details.product_id

Inner join orders ON orders.order_id=order_details.order_id

WHERE products.name=@vproduct AND

datepart(month,orders.order_date)=@vmonth AND

datepart(year,orders.order_date)=@vyear

go

EXECUTE sp_product_listing 'jack' , 'June' , '2001'



I get this ERROR: Msg 8114, Level 16, State 5, Procedure sp_product_listing, Line 0

Error converting data type varchar to datetime.

Can anyone help me. what am I doing wrong?
Thanks in advance.
Arlyn
1 Reply
Not applicable
Author

take @vmonth as varchar and @vyear as char(04)

regards

peter