|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Do I use a Stored Procedure?
I need to know if using a stored procedure is the way to go for a recordset I'm atempting to do.
I have two tables and the datasets look something like this Table 1 ID Date Info 1 10/01/03 blah 2 10/2/03 Blah Table 2 ID RefID Info 1 1 blah 2 1 more blah 3 2 la tee da My goal is to do an inner join that will give me the distinct RefID's in table 2 but sorted by the date from the join. Make sense? Sorry my lingo isn't up to snuff. TIA, John |
|
#2
|
||||
|
||||
|
yes, you could do something like this
Code:
CREATE PROCEDURE procName AS SELECT distinct table2.RefID, table1.[date] from table1, table2 where table2.RefId = table1.ID ORDER BY table1.[date] GO based on the data you supplied above it would display the following. Code:
RefID Date 1 2003-10-01 00:00:00.000 2 2003-10-02 00:00:00.000 |
|
#3
|
|||
|
|||
|
Thanks, it worked wonderfully. But because of it's simplicity I think a SP is overkill right? I used it as a regular query in my ASP page, there shouldn't be any real disadvantage to that. Correct?
John |
|
#4
|
||||
|
||||
|
The advantage to using a Stored Procedure over passing an actual query statement to the database is...A stored procedure is already compiled and will execute faster, however on something this simple you wouldn't even notice the execution time.
So either way would be fine in this case. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Do I use a Stored Procedure? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|