March 22, 2006 at 3:57 am
@sCode VARCHAR(20) , @ErrCode Integer OUTPUT
AS
BEGIN
SET
ProductCategory = 'STAT'
WHERE
Product_Code is null
IF (@ErrCode = 0)
COMMIT TRANSACTION
ELSE
ROLLBACK TRANSACTION
WHILE @@FETCH_STATUS = 0
BEGIN
EXEC (@sSQL)
IF @ErrCode <> 0 BREAK
Must declare the variable '@ErrCode'.
S A T ...
Sathish's Blog
March 22, 2006 at 5:13 am
i think you might have few problems doing it this way
1) the value you return from the child procedure is retuned as an output variable so you need to call it like this (see books on line)
declare @results integer
exec sp_myproc @errcode=@results OUTPUT
secondly - as your buildig string and calling the resultant string using EXEC() then any variables you declare or anythinig inside that EXEC block go out of scope after you finish the exec block.
for example
declare @strsql navrchar(100)
set @strsql='declare @fred int
set @fred=1
'
exec @strsql
select @fred
doens't work because @fred is created inside a diferrent thread and then destroyed when the exec completes.
MVDBA
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply