JimZ
JimZ

Reputation: 1202

Does Sql Server 2008 has column display name?

I actually didn't notice this, in Access 2003/2007, I could set column display name different from its name in sql query string. But in sql server 2008, I couldn't find this option. I found "Description" but it's not what I want.

I think it's a very useful function that Sql Server 2008 should have. When I get data and display to DataGridView, the column name in sql query string displays, not quite friendly.

And I know I could embed my desired names in sql query string but that will take a lot of time if I have many columns, and it cannot be re-used.

I would greatly appreciate if someone could help me set "Column Display Name" in Sql Server 2008, thanks guys :)

this is the table setup page, no 'column display name'

I need the column name displaying instead of col,col2....

Upvotes: 0

Views: 1465

Answers (3)

dmportella
dmportella

Reputation: 4724

Unfortunately this feature is not available in SQL server however you can name properties anyway you like including add spaces to them.

It is also possible for you to rename fields of the fly when you query them by using the "AS" keyword in T-SQL (check the select statement to see column aliases)

Example

Select col1 as [Hello World] from table1

The "[,]" are qualifiers to ensure column names don't conflict with any keywords and should be used if you have spaces in your column name.

DataGridView has also the ability to set column names please check the links below for further information.

Upvotes: 3

Praveen Nambiar
Praveen Nambiar

Reputation: 4892

SQL Server doesnt have this functionality.
You can set the column name by doing the following:

SELECT ColumnName AS 'DesireColumnName'

Or Create a View with your desiredcolumn name. So the new column names will become reusable when used in a View.

Upvotes: 0

RedDevil79
RedDevil79

Reputation: 445

you can use this:

select col1 as mycolumname from ...

Upvotes: 0

Related Questions