| Author |
Topic |
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-04-01 : 17:19:17
|
| How can we write a script that will provide me colmumns and all differnt set of values for those columns...there are 300 plus columns all together. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-01 : 17:20:54
|
| Could you provide a data example of what you mean?Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-04-01 : 17:32:04
|
| There are columns like Prefix, Suffix, Fec_1, dist, state, county, .... some_flag, code.. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-01 : 17:33:37
|
| That doesn't make it more clear.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-01 : 17:35:24
|
| If you need help from experts be clear in what you write? |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-04-01 : 17:44:30
|
| Say if we have a table with 300 columns and each column has set of values...I need to find out what are distinct values in each columns?Hope this makes sense..thanks! |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-01 : 17:51:07
|
| Script the 300 queries like this:SELECT 'SELECT DISTINCT ' + COLUMN_NAME + ' FROM ' + TABLE_NAMEFROM INFORMATION_SCHEMA.COLUMNSWHERE TABLE_NAME = 'YourTable' <--modify thisThen copy and paste into a new window and execute it.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-04-01 : 17:55:19
|
| How can I put that in one report? There will 300 separate results rite using this? |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-01 : 17:56:03
|
| I have no idea how you are going to put this into a report. If you want to know the distinct values in each column, then you need 300 queries.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-04-01 : 17:59:22
|
| I need to have something like :age_ctgry543statemdvadc |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2008-04-01 : 18:07:25
|
| You could union all of them together to get your desired output, but you are most likely going to run into data type issues.Tara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
GhantaBro
Posting Yak Master
215 Posts |
Posted - 2008-04-01 : 18:09:15
|
| yeah plus there won't be any separator. |
 |
|
|
|