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 |
|
sqlneve
Starting Member
16 Posts |
Posted - 2009-01-21 : 13:03:01
|
| I want to select all records from 3 different tables and then export out all 3 as one. Below is what I thought might work. But this didn't get me very far. Can anyone hep? Would this be an insert into query? Thanks!SELECT *FROM sdeallsites.dbo.arall1AND sdeallsites.dbo.arallAND sdeallsites.dbo.arsw |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-21 : 13:06:08
|
| [code]SELECT *FROM sdeallsites.dbo.arall1 t1JOIN sdeallsites.dbo.arall t2ON t2.field=t1.fieldAND sdeallsites.dbo.arsw t3ON t3.field={t1/t2}.field[/code]fields represent column by which tables are related |
 |
|
|
askben
Starting Member
8 Posts |
Posted - 2009-01-21 : 18:23:30
|
| SELECT *FROM sdeallsites.dbo.arall1UNION ALLSELECT * FROM sdeallsites.dbo.arallUNION ALLSELECT * FROM sdeallsites.dbo.arswThis will union all the tables together into one rowset to return.------------Ben Miller |
 |
|
|
TechnoConnect Team
Starting Member
1 Post |
Posted - 2009-01-22 : 00:39:07
|
| SELECT Col1, Col2, Col3FROM sdeallsites.dbo.arall1UNION ALLSELECT Col1, Col2, Col3FROM sdeallsites.dbo.arallUNION ALLSELECT Col1, Col2, Col3FROM sdeallsites.dbo.arswJust to add to Ben Miller's Reply, pls follow the syntax given above to includ the column names in your select statement, this will improve the performance of the SELECT statement. Also make sure that Col1, Col2, Col3 etc in all three SELECT statements appear in the same sequence (irrespective of sequence in table) and have the same data types.Hope this helps!| TechnoConnect Team | http://www.techno-connect.blogspot.com || This info is provided "AS IS" with no warranties & confers no rights. | |
 |
|
|
|
|
|