Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Question about Stored procedure

Author  Topic 

zoom14151
Starting Member

34 Posts

Posted - 2006-03-23 : 11:16:45
You guys have helped me in the past and I need your help again. I need to put a search page in asp.net and I would like to use a store procedure. This page will search four tables for records. To start I need to pass a parameter to the log table to get the (ID's) of all the records that have a value in the (Area column). I get the Area value from the previous page. This will return several records. Next I need to pass the (ID's) to the three other tables (They have a "Journal_id" that is the same as the log tables (ID)) and retrieve those records and display the records from the three tables in separate datagrids on one web page.

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-23 : 11:33:02
For ur First Part of Requirements :

Create Procedure UrProc (@pArea <datatype>)
as

Select IDs from log_Table Where Area = @pArea

-- I can't understand the following;
>> I get the Area value from the previous page.

I think u may need 3 Stored Procedures or Functions

For eg, consider data for Grd1:

Create Procedure UrProc1 (@pArea <datatype>)
as
Select * from Journal_1
Where Journal_id in (Select IDs from log_Table Where Area = @pArea)

Returns data from 1 table

U might extend this
Go to Top of Page

zoom14151
Starting Member

34 Posts

Posted - 2006-03-23 : 14:59:58
I wrote three store procedure that worked. Could it been done with one?
Go to Top of Page

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2006-03-23 : 15:14:51
quote:
Originally posted by zoom14151

I wrote three store procedure that worked. Could it been done with one?



I doubt it, as one can return only one set of records
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-24 : 05:01:20
Use four select statements in the sp. Then the recordset have four result set. Use table(index) to access all the tables

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -