Maybe a Crazy Idea? Build a Custom Dynamic Summary of a Table..
What I'd like to do is be able to feed a table name into my procedure, and then have it search through the fields in the table, and basically more or less give me these results:
1. Whether the column contains ALL NULLS or not
2. What the format of the column is
3. If the column is numeric, then the Max, Min, Median, Average
4. If the column is varchar or nvarchar, then perhaps the values from the top 2 or 3 non-null records.
5. Any oddities I can think of to be added in later, perhaps.
Once the above is done, I'd like to then loop through the columns, and select the NON-NULL columns, leaving those that are all NULLs. And the other columns, I may do something differently with them based on format, certain numeric thresholds, etc. And that may actually vary each time.
But if I could just get the summary built dynamically as start, that's really what I'm after.
I've read of using Cursors, and may have used one once, but don't remember at the moment. I'd imagine I have to loop through or use a cursor to accomplish this.
Thanks for any thoughts or suggestions on this.
I'll try to add a mock-up of what I'd like to output as the temp table hopefully soon.
What I'd like to do is be able to feed a table name into my procedure, and then have it search through the fields in the table, and basically more or less give me these results:
1. Whether the column contains ALL NULLS or not
2. What the format of the column is
3. If the column is numeric, then the Max, Min, Median, Average
4. If the column is varchar or nvarchar, then perhaps the values from the top 2 or 3 non-null records.
5. Any oddities I can think of to be added in later, perhaps.
Once the above is done, I'd like to then loop through the columns, and select the NON-NULL columns, leaving those that are all NULLs. And the other columns, I may do something differently with them based on format, certain numeric thresholds, etc. And that may actually vary each time.
But if I could just get the summary built dynamically as start, that's really what I'm after.
I've read of using Cursors, and may have used one once, but don't remember at the moment. I'd imagine I have to loop through or use a cursor to accomplish this.
Thanks for any thoughts or suggestions on this.
I'll try to add a mock-up of what I'd like to output as the temp table hopefully soon.