create proc dbo.Proc_Get_Data
@iYear as int,
@iMonth as int,
@ItemCode varchar(50),
@type varchar(50), @GroupType varchar(50)=''
as if @GroupType=''
begin
select * from table where iYear=@iYear and @iMonth=@iMonth and ItemCode= @ItemCode and type=@type
endGO--==
select * from table where iYear='2007' and iMonth='8' and itemcode='All'and type='库存物料‘结果:可以取得记录。
exec Proc_Get_KPI_Data N'2007', N'8',N'All', N'库存物料,''
结果:不可以取得记录。
请问2种方法主要有什么区别啊。急。。
@iYear as int,
@iMonth as int,
@ItemCode varchar(50),
@type varchar(50), @GroupType varchar(50)=''
as if @GroupType=''
begin
select * from table where iYear=@iYear and @iMonth=@iMonth and ItemCode= @ItemCode and type=@type
endGO--==
select * from table where iYear='2007' and iMonth='8' and itemcode='All'and type='库存物料‘结果:可以取得记录。
exec Proc_Get_KPI_Data N'2007', N'8',N'All', N'库存物料,''
结果:不可以取得记录。
请问2种方法主要有什么区别啊。急。。
不好写的,如循环,判断,不固定的值...用存储过程
@iMonth as int,
iYear= '2007 ' and iMonth= '8 '
exec Proc_Get_KPI_Data N '2007 ', N '8 ',N 'All ', N '库存物料, ' '
明显类型不一样啊,把存储过程的变量类型改了
@iMonth as int,
应该是这两个变量的类型有问题。改成你创建表时这两个字段的类型。
exec Proc_Get_KPI_Data N'2007', N'8',N'All', N'库存物料', ''