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 |
|
Vack
Aged Yak Warrior
530 Posts |
Posted - 2010-12-06 : 09:47:14
|
| I have two tables that are almost identical. An Open Order Table and a History Table. Is there a way to create a SQL view that will list all records in both tables? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2010-12-06 : 09:51:28
|
| CREATE VIEW All_Orders ASSELECT col1, col2, col3 FROM OpenOrdersUNION ALLSELECT col1, col2, col3 FROM OrderHistoryChange the column list in both SELECT statements to meet your needs. |
 |
|
|
vaibhavktiwari83
Aged Yak Warrior
843 Posts |
Posted - 2010-12-06 : 09:54:16
|
quote: Originally posted by Vack I have two tables that are almost identical. An Open Order Table and a History Table. Is there a way to create a SQL view that will list all records in both tables?
CREATE VIEW YourViewASSELECT <ColumnList>, 'O' FROM OpenOrderTable UNION ALLSELECT <ColumnList>, 'H' FROM OpenOrderTableHistory'O' Or 'H' to Identify data is from which table. If you dont have column in tablesVaibhav TIf I cant go back, I want to go fast... |
 |
|
|
|
|
|