Z
zpselect
Unregistered / Unconfirmed
GUEST, unregistred user!
现在有两个存储过程,其中一个存储过程在运行时需要调用别一个带有参数的存储过程,请问怎样写才对?
存储过程一:
CREATE PROCEDURE GetSerialBH
@PCBH Varchar output,
@printerBH Varchar output,
@VGABH Varchar output
as
Declare
@pc char(6),
@print char(6),
@VGA char(6)
BEGIN
SELECT @PC=MAX(PJ_BH) FROM PJBH WHERE PJ_LB='M' /****M:代有主机****/
SELECT @Print=MAX(PJ_BH) FROM PJBH WHERE PJ_LB='P' /**** P:代表打印机*****/
SELECT @VGA=MAX(PJ_BH) FROM PJBH WHERE PJ_LB='V' /**** V:代表显示器*****/
set @PC=ReturnValue(@PC) //调用存储过程二,但是调试错误!
END
GO
存储过程二:
CREATE PROCEDURE ReturnValue
@Value Varchar(7)
AS
Declare
@i int ,
@s varchar(7) ,
@n int
set @i=1
set @n=Convert(int ,Substring (@Value,4,4)) /*ubstring(COM0001,4,4)=0001**/
set @s= isnull(@s,'')
while @i<=4-Len(@n)
begin
set @s=@s+'0'
set @i=@i+1
end
Select @s+Convert(varchar ,@n)
GO
存储过程一:
CREATE PROCEDURE GetSerialBH
@PCBH Varchar output,
@printerBH Varchar output,
@VGABH Varchar output
as
Declare
@pc char(6),
@print char(6),
@VGA char(6)
BEGIN
SELECT @PC=MAX(PJ_BH) FROM PJBH WHERE PJ_LB='M' /****M:代有主机****/
SELECT @Print=MAX(PJ_BH) FROM PJBH WHERE PJ_LB='P' /**** P:代表打印机*****/
SELECT @VGA=MAX(PJ_BH) FROM PJBH WHERE PJ_LB='V' /**** V:代表显示器*****/
set @PC=ReturnValue(@PC) //调用存储过程二,但是调试错误!
END
GO
存储过程二:
CREATE PROCEDURE ReturnValue
@Value Varchar(7)
AS
Declare
@i int ,
@s varchar(7) ,
@n int
set @i=1
set @n=Convert(int ,Substring (@Value,4,4)) /*ubstring(COM0001,4,4)=0001**/
set @s= isnull(@s,'')
while @i<=4-Len(@n)
begin
set @s=@s+'0'
set @i=@i+1
end
Select @s+Convert(varchar ,@n)
GO