0

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....

Community
  • 1
  • 1
JimZ
  • 1,182
  • 1
  • 13
  • 30

3 Answers3

3

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.

Community
  • 1
  • 1
dmportella
  • 4,614
  • 1
  • 27
  • 44
  • 1
    Thanks dmportella, great links. Also thanks other guys, I take this as answer coz it has many useful links :) – JimZ Mar 09 '13 at 10:39
0

you can use this:

select col1 as mycolumname from ...
RedDevil79
  • 445
  • 5
  • 13
0

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.

Iswanto San
  • 18,263
  • 13
  • 58
  • 79
Praveen Nambiar
  • 4,852
  • 1
  • 22
  • 31