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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2000-12-17 : 11:42:10
|
Terry writes "Hi,
I hope you can help. I would like to find out how to write a stored procedure that would return a result similiar to a union queries.
Here is the problem:
TableName: tblJob
Record 1: JobID = 1 FileNo = 1000 PreviousJobID = 2
Record 2: JobID = 2 FileNo = 2000 PreviousJobID = Null
I can return my desired result set with a union join to produce the following:
JobID FileNo PreviousJobID 1 1000 2 2 2000 Null
Basically I start at Record 1, and want to get the next JobID that = my Record1.PreviousJobID and keep going until PreviousJobID = null.
I'm not sure how to write a union join in a stored procedure. I can provide Record1 with the JobID but I then want to output the rest of the JobID's that the procedure retrieves.
Can you help or have any suggestions? I am using Access97 as the front end, SQL Server 7 as the back end, on an NT4 machine.
Thanks
Terry" |
|
|
|
|
|