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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 HeLp!

Author  Topic 

mason
Starting Member

11 Posts

Posted - 2003-06-09 : 16:04:41
Trying to figure out how to create a stored procedure that will return records from two tables (Table 1 and Table 2) linked on an ID field which is part of table 1 as an equal join. I have to use OJ syntax.

Any help would be greatly appreciated.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-06-09 : 16:11:18
Mason, you haven't really given much information. But here is a sample:

CREATE PROC usp_SampleProc
AS

SELECT a.Column1, b.Column3, a.Column2
FROM Table1 a
INNER JOIN Table2 b ON a.Column1 = b.Column1

RETURN


BTW, is this a homework assignment? Also, what is OJ syntax?

Tara
Go to Top of Page

mason
Starting Member

11 Posts

Posted - 2003-06-09 : 16:12:48
Hi Tara,

It's self study. As for OJ Syntax, that's Outer Join syntax.

Go to Top of Page

chadmat
The Chadinator

1974 Posts

Posted - 2003-06-09 : 21:58:03
You would still use Tara's query, just change INNER to LEFT, or RIGHT depending on which table you want all of the rows from.

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page
   

- Advertisement -