Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / August 2008

Tip: Looking for answers? Try searching our database.

Metadata

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Morey - 30 Aug 2008 22:23 GMT
Hi --

I am looking to migrate an old application built with ASP and running on SQL
Server 2000 to a RIA type app possibly using Java and SQL Server 2008. I
have been reading about SQL MetaData and I am curious to know if the
information obtained via the getColumnLabel() function in Java can be stored
as metadata in SQL Server.

From what I have read so far this column label data comes when you do a
SELECT FIELD as OTHERNAME, the column label would be "OTHERNAME" What I
would ideally like to do is store a text string that would be used as a
caption for a field. For example, the field FIRSTNAME would have a column
label of "First Name" Is this possible in SQL Server 2008?

Thanks

Rich
Daniel Jameson - 31 Aug 2008 04:07 GMT
Rich,

I don't believe there is any way to put a default override for column names,
because how would you then ever get the real name from a SELECT query.
However you can create a view to have alternate column names.

CREATE VIEW vSpelledOut AS
SELECT FIRSTNAME AS [First Name], ...
FROM MyTable

Note that you need to use [] (or some other delimeter based on server
settings) to delimit identifiers with spaces or other special characters.

Signature

Thank you,

Daniel Jameson
SQL Server DBA
Children's Oncology Group
www.childrensoncologygroup.org

> Hi --
>
[quoted text clipped - 13 lines]
>
> Rich
Richard Morey - 31 Aug 2008 04:26 GMT
Hi --

Thanks for the feedback. I don't want to override the column names, but it
appears to me that Java supports a getColumnLabel() and getColumnName()
which are the same unless a select query uses an AS statement. I was hoping
I could associate a column label parameter with the column name.

I appreciate your idea of the view, however, I would like to have the column
label parameter available whenever I did a select query and not have to do a
seperate query to get the labels.

Thanks,

Rich

> Rich,
>
[quoted text clipped - 26 lines]
>>
>> Rich
Andrew J. Kelly - 31 Aug 2008 15:09 GMT
I am not sure I follow you here. If you want a different name or label for a
column the appropriate and preferred method is to use an alias as Daniel
suggested in the query itself of using a view. I don't see how you intend to
get a label if the column does not use an alias without making two calls. I
don't know of the getColumnLabel() function in Java but it appears to
require an alias to work. So you either need a predefined object that has
the labels you require or you need to make additional calls. You can use the
SQL Server extended property to assign a description to pretty much any
object but you cannot retrieve this information via the select. Again that
is what alias's are for. But you may want to check out the extended
properties in BooksOnLine to see if they will get you closer to your goal
but I think what you are asking for is not feasible.

Signature

Andrew J. Kelly    SQL MVP
Solid Quality Mentors

> Hi --
>
[quoted text clipped - 41 lines]
>>>
>>> Rich
Richard Morey - 31 Aug 2008 16:15 GMT
Hi --

I was hoping to store the alias so that if, for example, I did a SELECT *
FROM TABLE the alias would be available via the getColumnLabel() while the
field name would be available via getColumnName(). I think you are right in
that what I want to do is not feasible so I will look into creating a view
or storing the information in some other way.

Thanks for your help.

Rich

>I am not sure I follow you here. If you want a different name or label for
>a column the appropriate and preferred method is to use an alias as Daniel
[quoted text clipped - 56 lines]
>>>>
>>>> Rich
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.