Reputation: 1202
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 :)
Upvotes: 0
Views: 1465
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
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