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 2008 Forums
 Transact-SQL (2008)
 Merging two tables for a view

Author  Topic 

salthead
Starting Member

8 Posts

Posted - 2011-01-04 : 21:45:35
I'd like to create a view by using two tables and merging them as such:

Table 1
ID Description
01 This is my first Description
02 This is my second Description
03 This is my third Description

Table 2
ID Description
01 Description 1
02 Description 2

Resulting View
ID Source Description
01 Table 1 This is my first Description
02 Table 1 This is my second Description
03 Table 1 This is my third Description
01 Table 2 Description 1
02 Table 2 Description 2


Is this possible with sqlserver? And if so, what would be the best way to accomplish this task?

X002548
Not Just a Number

15586 Posts

Posted - 2011-01-04 : 22:31:55
SELECT [ID], [Description]
FROM Table 1
UNION ALL
SELECT [ID], [Description]
FROM Table 2



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

salthead
Starting Member

8 Posts

Posted - 2011-01-06 : 22:00:36
Thanks for the help!! That's exactly what I needed, and no matter how I tried, I couldn't form a web search that would give me the info.
Go to Top of Page
   

- Advertisement -