日期:2014-05-18  浏览次数:20432 次

关于存储过程的简单问题,麻烦给说明一下哈
在自学存储过程,看示例有一个地方不太明白,请大家给说明一下
....部分略.....
declare   @intEqTypeId   int,
@intEqupmentId   int

--   read   Id   of   EqType
Select   @intEqTypeId
From   EqType
Where   EqType   =   @chvEqType
....部分略.......
涉及到的表EqType有两个字段:EqTypeID(设备ID号),EqType(设备名称)
主要是select   @intEqTypeId这一句,系统怎么知道它是要读符合条件的设备ID号而不是其它呢?如果表中还有一个字段Exp1,那怎么能知道@intEqTypeId得到的是ID号还是Exp1的值?

------解决方案--------------------
写法不对,正确写法:

declare @intEqTypeId int,
@intEqupmentId int

-- read Id of EqType
Select @intEqTypeId=EqTypeID
From EqType
Where EqType = @chvEqType