How can i know which columns are ununsed in my table?

  • Hello

    how can i know which columns are used or which are not used ??

    Is there any sp ??

    Please help..

  • Please explain about what "columns" you have in mind, and who is "using" them.

    Are you suggesting that some dynamic procedure is executing and you want to know which columns it is using??...Your post needs a little more explanation in order for us to make out what your requirement is.

    Vinu Vijayan

    For better and faster solutions please check..."How to post data/code on a forum to get the best help" - Jeff Moden[/url] 😉

  • Hello,

    Using below sp you will find which column used in which tables,

    SELECT t.name AS table_name, SCHEMA_NAME(schema_id) AS schema_name, c.name AS column_name

    FROM sys.tables AS t INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID

    WHERE c.name LIKE '%Your Column Name%' ORDER BY schema_name, table_name;

  • Please explain about what "columns" you have in mind, and who is "using" them.

    Are you suggesting that some dynamic procedure is executing and you want to know which columns it is using??...Your post needs a little more explanation in order for us to make out what your requirement is.

    No no.... I want to find out those columns which are not used in any where in any database ....

    ex : when we create table than we add some columns but some time some columns are not needed though we create it... like that i want to find out those unused columns....

  • As far as I know, SQL Server doesn't out-of-the-box record and save column-usage statistics. You'll need to implement your own method here. You can get creative with a DML trigger on a table, but this will only capture INSERT/DELETE/UPDATE statements, not SELECTs if that's also what you're interested in.



    Twitter: @SQLife
    Email: sqlsalt(at)outlook(dot)com

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply