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 |
|
latent_ken
Starting Member
10 Posts |
Posted - 2011-09-12 : 10:57:41
|
| Hi I have 8 tables that i need to combine into one. I wanted to use a view for this but the problem is that my select statement has over 1024 columns. I would just use a select * statement but then i have the same user id column repeated. Is there a way that i could remove the columm after the select * ? |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-09-12 : 11:02:12
|
| You'd have to list each column explicitly. You're also limited to 4096 columns per SELECT statement so you don't have much margin. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-09-12 : 11:25:17
|
| [code]SELECT CHAR(9) + '[' + TABLE_NAME + '].[' + COLUMN_NAME + '] AS [' + COLUMN_NAME + '],'FROM INFORMATION_SCHEMA.COLUMNSWHERE TABLE_NAME IN ('MyTable1', 'MyTable2')ORDER BY TABLE_NAME, ORDINAL_POSITION[/code]will get you a list you could hack about |
 |
|
|
latent_ken
Starting Member
10 Posts |
Posted - 2011-09-12 : 12:04:27
|
| what does the char(9) do exactly ? |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2011-09-12 : 12:31:02
|
TAB - which will make your code look neat |
 |
|
|
|
|
|