jfreeman2010
asked on
t-sql help - stored procedure call anther stored procedure
I need help on #2 and #3:
1) select data from a table, stored the STD_ID in the temp table.
2) need to execute anther stored procedure 'GET_STD_INFO ' pass in the STD_ID, it will return columns included the following:
STD_ID, STD_NAME, ACTIVE_IND AND CLASSES_TOTAL, etc...
3) need to update the temp table with the return columns of STD_ID, STD_NAME, ACTIVE_IND AND CLASSES_TOTAL
DECLARE @TMP_TEST table
(
STD_ID INT,
STD_NAME VARCHAR(50),
ACTIVE_IND CHAR(1),
CLASSES_TOTAL INT
)
INSERT @TMP_TEST
(
STD_ID
)
SELECT DISTINCT
TOP 1 STD_ID
FROM STUDENT_TB
ORDER BY ACTIVE_YEAR
what is the best way to do this?
thank you,
I am running in MS SQL server 2010.
1) select data from a table, stored the STD_ID in the temp table.
2) need to execute anther stored procedure 'GET_STD_INFO ' pass in the STD_ID, it will return columns included the following:
STD_ID, STD_NAME, ACTIVE_IND AND CLASSES_TOTAL, etc...
3) need to update the temp table with the return columns of STD_ID, STD_NAME, ACTIVE_IND AND CLASSES_TOTAL
DECLARE @TMP_TEST table
(
STD_ID INT,
STD_NAME VARCHAR(50),
ACTIVE_IND CHAR(1),
CLASSES_TOTAL INT
)
INSERT @TMP_TEST
(
STD_ID
)
SELECT DISTINCT
TOP 1 STD_ID
FROM STUDENT_TB
ORDER BY ACTIVE_YEAR
what is the best way to do this?
thank you,
I am running in MS SQL server 2010.
seem like an assignment to me ?
ASKER
Its better way to do this beside to DECLARE CURSOR on #2?
yes, you can do that withou a cursor. but we are not suppose to provide answers to the assignments
ASKER
Hi aneeshattingal,
I don't understand what you mean assignments????
I don't understand what you mean assignments????
ASKER
this is NOT a student assignment, the example above just to make it easy to understand ( at lease if for me), and it part of what I need to do for work.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi aneeshattingal,
THANK YOU FOR HELP!!! I think will just make it easy to ask the question.
I have 2 questions :
1) can the #tmp be @tmp as table variable ?
2) what happen is the get_std_info return more columns then the #tmp/@tmp table list columns? do I need to list all the columns return from get_std_info in the #tmp/@tmp?
Thank you very much for help.
THANK YOU FOR HELP!!! I think will just make it easy to ask the question.
I have 2 questions :
1) can the #tmp be @tmp as table variable ?
2) what happen is the get_std_info return more columns then the #tmp/@tmp table list columns? do I need to list all the columns return from get_std_info in the #tmp/@tmp?
Thank you very much for help.
Hi,
yes the #temp table can be used as @temp variable and you might need to tweak the get_std_info to return only the columns that you like to insert into the Temp table.
yes the #temp table can be used as @temp variable and you might need to tweak the get_std_info to return only the columns that you like to insert into the Temp table.
ASKER
ok, I will try. thank you very much for your helping...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
YES Aneesh, that is what I am trying to do, and the logic is very complex and I am still working.... thank you for your suggestion.
ASKER
thank you for all your help!!!