Create a view from two tables having different number of Columns
-
2012년 5월 7일 월요일 오전 7:17
Hi,
I want to construct a view in T-SQL by combining (like UNION ALL) two or more tables with different no. of columns.
Eg. TABLE1 contains 3 columns (all VARCHAR) and 2 rows, TABLE2 contains 4 columns (all VARCHAR) and 4 rows. I would like the resultant view to be of 4 columns and 6 rows by combining these two tables. Retaining column names is not important
PS : These tables are determined dynamically, so there is no way of knowing how many columns would be there beforehand. The only guarantee is that the ALL THE COLUMNS would be of the type VARCHAR
- 편집됨 devROGUE 2012년 5월 7일 월요일 오전 7:21
모든 응답
-
2012년 5월 7일 월요일 오전 7:49답변자
best ask in the T-SQL forum: http://social.technet.microsoft.com/Forums/en-US/transactsql/threads
this forum is mainly for profile and recognition system topics
- 답변으로 제안됨 Ed Price - MSFTMicrosoft Employee, Owner 2012년 5월 7일 월요일 오후 5:57
- 답변으로 표시됨 Ed Price - MSFTMicrosoft Employee, Owner 2012년 5월 7일 월요일 오후 6:27
-
2012년 5월 7일 월요일 오후 12:44
If the tables are generated dynamically, perhaps you need to generate the view dynamically as well if it has to be a view.For every expert, there is an equal and opposite expert. - Becker's Law
My blog- 답변으로 제안됨 Ed Price - MSFTMicrosoft Employee, Owner 2012년 5월 7일 월요일 오후 5:56
-
2012년 5월 7일 월요일 오후 5:57소유자
best ask in the T-SQL forum: http://social.technet.microsoft.com/Forums/en-US/transactsql/threads
this forum is mainly for profile and recognition system topics
DevRogue, let us know if you want us to move it there. Also, check out Naomi's answer and mark it if it helps you solve this issue. Thanks!Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)
-
2012년 5월 7일 월요일 오후 6:13Sure, please move it there and also please merge to his other thread which is the same and already answered.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog -
2012년 5월 7일 월요일 오후 6:13
I created a new thread on the tsql forum..
and i also got an answer there..
so please delete this thread..
Sorry for the inconvenience.