none
Renaming column names in Query

    Question

  • Is there a way to rename a column name in a query?

    I have a different Priority field in our WorkItem type called DashPriority but as far as the User is concerned it is Priority. When I add Dash priority to the a Work Item Query it displays "DashPriority" as a column header.

    I am sure most people want to rename these column headers but I can't seem to find where to change them.

    Thursday, August 31, 2006 11:40 PM

Answers

  • I do not think there is a way. I did a quick look into code but I do not see any apparant way to enable users to specify different friendly name in query result headers. We have reference name & friendly name for this purpose. Just curious, supposing we provide such feature, where (in UI or otherwise) do you think is best place for your to configure such names?

     

    Friday, September 01, 2006 12:53 AM

All replies

  • I do not think there is a way. I did a quick look into code but I do not see any apparant way to enable users to specify different friendly name in query result headers. We have reference name & friendly name for this purpose. Just curious, supposing we provide such feature, where (in UI or otherwise) do you think is best place for your to configure such names?

     

    Friday, September 01, 2006 12:53 AM
  • do you mean in SQL?
    forexample you have table
    table1
    colA
    colB
    colC
    create a view that resturn

    Select
        colA as ColumA,
        colB as ColumB,
        colC as ColumC
    From table1


    then when  you query your view you header will change to ColumA ColumB ColumC
    .

    If you doing it in your DataGrid you may need to modify your ColumnStyle to change the header
    Friday, September 01, 2006 2:02 AM
  • How about in your query builder. You specify column order and sort order. Most apps just add a Rename button in that dialog.

    Another method we use in our application is allowing the user to in place edit column names by right clicking on the column header and selecting rename.

    Friday, September 01, 2006 6:37 PM
  • Yeah I know how to do that easily enough using SQL but I am thinking of the Queries node in Team Explorer. Doesn't look like I can do this in WIQL.
    Friday, September 01, 2006 6:39 PM
  • How do we change the Name Like

    I have Table with Name

    Table_1
                 col_1
                 Col_2
                 Col_3

    my query Change My Col_1 name to Col5 permanently not in view only and also i don't want to loose my data which is stored in Col_1

    i have tried couple of queries but its not working like.

    Alter Table TableName change oldColumn  NewColumn Datatype Notnull

    can some one help me out
    Thursday, September 10, 2009 5:28 AM
  • I've got exactly the same issue: I've tried with and without "AS", I've tried with single and double quote... the funny thing is that whenever I execute the query and go back to the SQL code, the code has been altered in such a way that all the renaming stuff is gone.

    ex.
    select column_a AS "firstColumn" 
    from
    table T

    when I execute this I get

    column_a
    -----------
    blablabla
    blablabla
    blablabla

    when I go back to the code it says

    select column_a  
    from
    table T

    so without the AS "firstColumn" 
    Thursday, October 01, 2009 2:45 PM
  • Open the SQL Server Management Studio -> Databases -> tfsWorkItemTracking -> Tables -> dbo.Fields -> right click and open table.
    Here change the values of Name and NewName fields to any new values you want.
    • Proposed as answer by rockstorm Thursday, September 16, 2010 2:23 PM
    Thursday, September 16, 2010 2:17 PM
  • Hi, i have found in MS Query, the way is a bit different to rename the field header:

     

    select

    Priority = DashPriority

    from MyTable

    Monday, November 29, 2010 8:17 PM
  • Be very very careful when making changes directly against the SQL databases. I'm pretty sure it's not supported or recommended by MSFT. [i.e if you call PSS for support they run a tool to verify integrity and if it doesn't pass you are on your own and SOL]

    You can break all of your SSRS reports and the data that is in the TFS OLAP cube. I would recommend using the TFS Power Tool editor and uploading a new WIT definition with the change in the name.

    Tuesday, November 30, 2010 5:18 PM