I have a database with two tables (Table1 and Table2). Table1 has one column ColumnA and Table2 has one column ColumnB i want to select both the columns,
looking for something like:
ColumnA in Table1:
a
b
c
ColumnA in Table2:
d
e
f
Result set should be:
a d
b e
c f
Thanks in advance..
I am pretty sure sql server 2000 supports table vars so you can try this
DECLARE @TableA TABLE(
ID INT IDENTITY(1,1),
Val VARCHAR(50)
)
INSERT INTO @TableA (Val) SELECT ColumnA FROM Table1
DECLARE @TableB TABLE(
ID INT IDENTITY(1,1),
Val VARCHAR(50)
)
INSERT INTO @TableB (Val) SELECT ColumnB FROM Table2
SELECT a.Val,
b.Val
FROM @TableA a INNER JOIN
@TableB b ON a.ID = b.ID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With