一个关于datetime类型的模糊查询
编写一存储过程,查询指定客户在指定时间段内购买指定产品的数量,存储过程中使用了输入和输出参数。并调用该存储过程查询名称为“家电市场”的客户在2004年购买“洗衣机”的数量。
create function getStock2(@customerName char(30),@time datetime,@productName char(30)) returns intasbegin declare @Stock int; select @Stock=cpxsb.数量 from cp,cpxsb,xss where cp.产品编号=cpxsb.产品编号 and cpxsb.客户编号=xss.客户编号 and 客户名称=@customerName and 产品名称=@productName and 销售日期=@time return @Stockend
create function getStock2(@customerName char(30),@time datetime,@productName char(30)) returns intasbegin declare @Stock int; select @Stock=cpxsb.数量 from cp,cpxsb,xss where cp.产品编号=cpxsb.产品编号 and cpxsb.客户编号=xss.客户编号 and 客户名称=@customerName and 产品名称=@productName and 销售日期=year(@time) return @Stockend
[解决办法]