stored procedures - Trying to access the results/result-set of a SQL server EXEC statement -
Say I have stored 1 store nearby, which gives some data. How can I execute that stored proc and set some parameters in another stored process based on the results of that stored proc? For example: Table:
UserInfo [UserID [Pro [], name [varchar], DateOfBirth [datetime])
stored in Pro 1: < / P>
process >> Process processed Proc1 @ name [varchar] Select UserID, name, DateOfBirth from the name of user information = @ Name
Pro 2:
Processed Process Processed 2 AmountOfNames [int] Selection @ AmountOfNames = COUNT Exec StoredProc1 @ name = 'Irwin')
I know That archived propose 2 is not how to make it But that's what I want to do, set the count on the basis of the last set
I stored proc 1
Can not modify a temporary table or table variable in your first stored proc ...
announcement @ My results tab (User Id Int. , Name varchar (30), dateoffetime datetime) INSERT @merezstExicStoredProject1 'Scott' - - What do you want to do with the table here They are ...
Or - You can use the @@ ROWCOUNT variable, to count the results of your first propose, after selecting the selection statement in your first stored process. It depends on whether or not it can work ...
DECLARE @ calculation int EXEC StoredProc1 'Scott' SET @Count = @@ ROWCOUNT -
If you do not have control over Store Propyep 1, then the Temple Table can be your best option as you know the result of @ T can not give up after being reset by @ROWCOUNT, code selected statement in your StoredProc1 proc.
Comments
Post a Comment