We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

SQL count used columns

Medium Priority
294 Views
Last Modified: 2012-05-07
hi there
I want a SQL statement with which i get all views with more than 230 columns AND which shows me which of these columns are explicit used.

any help would be appreciated!
Comment
Watch Question

Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
CERTIFIED EXPERT
Awarded 2009
Distinguished Expert 2019

Commented:
This would help you fetch table names with more than 230 columns.

SELECT table_name
FROM information_schema.columns
GROUP BY table_name
HAVING count(*) > 230

Kindly explain me what you meant by explicit used..

Author

Commented:
I would like to see which columns are used and which are unused.....
SQL Server DBA & Architect, EE Solution Guide
CERTIFIED EXPERT
Awarded 2009
Distinguished Expert 2019
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview

Author

Commented:
If the column is filled with data --> the colum is used
if the column is empty --> the column is unused
Raja Jegan RSQL Server DBA & Architect, EE Solution Guide
CERTIFIED EXPERT
Awarded 2009
Distinguished Expert 2019

Commented:
Then you have to use a procedure to loop through all tables and find what are all the list of columns that are used and unused depending upon whether data is present in that table or not.

Can you kindly elaborate on your requirement so that I can think of some other possibilities.
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.