add a new column with its columnName and aliasName

  • hi

    i want to create a new column (through a vb.net app) for a table . the problem is that i want set an alias name for this Column . my goal is to use column name for programming and use column alias as a caption for datagridview columns. is there a T-SQL command for this reason . (CREATE A COLUMN WITH NAME AND ALIAS)

    thanks

  • Column aliasing is perfomed at selection, not as part of the column metadata (though you could do this via extended properties, I'm not sure how practical that would be to use).

    So name your column as you want to internally, then when selecting use he following syntax:-

    SELECT OriginalColumnName AS AliasColumnName

    FROM table

    Alternatively, you could create a view with the user friendly column name and then reference that in your code. This is probably the best method if you wish to enforce the column alias.

    Follow me on twitter @EvoDBACheck out my blog Natural Selection DBA[/url]

  • Matthew Darwin (5/15/2013)


    Column aliasing is perfomed at selection, not as part of the column metadata (though you could do this via extended properties, I'm not sure how practical that would be to use).

    So name your column as you want to internally, then when selecting use he following syntax:-

    SELECT OriginalColumnName AS AliasColumnName

    FROM table

    Alternatively, you could create a view with the user friendly column name and then reference that in your code. This is probably the best method if you wish to enforce the column alias.

    thank you very much ...

    how if i want to set a description for my column with T-SQL ? is that has the same problem?

    how can i create a column and define a description for my sql column for example through vb.net ?

Viewing 3 posts - 1 through 2 (of 2 total)

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