Tuesday, March 27, 2012

alias naming

Hi,
I want help regarding the following scenario...
My scenario is ...
I want to give description for each field somewhere in the database..
such that i should use that description as alias name in the SQL queries or Stored procedures...
For example...
Table : 'Table1'

Clumns Description

Field1 xxx
Field2 yyy

Query : Select Field1 as xxx , Field2 as yyy from Table1.

Mr requirement...
1.I want to specify tag or description for each field
2. if i change the description 'xxx' as 'x1x1x1',it should be automatically updated in the Query,Views,Storedproc.. wherever the table and the fields are referred.

can any one help me?.If you are storing alias name for columns,
you have to use dynamic sql, to get the results.

I think, your requirement is so complicated to implement. :D
What advantages you will get, if you implement it..? :rolleyes:

Regards,
Selva Balaji. B

Originally posted by durgadevi_n
Hi,
I want help regarding the following scenario...
My scenario is ...
I want to give description for each field somewhere in the database..
such that i should use that description as alias name in the SQL queries or Stored procedures...
For example...
Table : 'Table1'

Clumns Description

Field1 xxx
Field2 yyy

Query : Select Field1 as xxx , Field2 as yyy from Table1.

Mr requirement...
1.I want to specify tag or description for each field
2. if i change the description 'xxx' as 'x1x1x1',it should be automatically updated in the Query,Views,Storedproc.. wherever the table and the fields are referred.

can any one help me?. :D :D :D|||There isn't such a functionality within the database. Using the standard tools like Enterprise Manager or Query Analyzer, you have to use the physical names, and to assign the logical names every time again.

You may consider to make a view for each table assigning your logical names.

Client tools, however, can replace the physical names by logical ones in the user interface. Look, for example, the DB Explorer (http://www.DB-Explorer.com).|||Hi,
Actually in my application...
I am creating more stored procedures based on a single table...(database already used by another application).
Since i can't change the field names, i am making use of alias name for the required fields in Stored procedures and binding tha data in the front end where the alias name gets displayed.
I've more than 500 stored procedures in my database.
If I want to change a field caption ,
I cannot change the existing field's name since it is already used by other application.
Also It is very hard to find out and change the alias name in each and every stored procedure wherever it is referenced.

So i am trying to look in other chances...to reflect the change in every stored procedure with a single move.

Is it possible?...
plz help me...
bye
by
durga|||And what about using views? You may consider not to assign your alias within every stored proc, but once in a view definition. If you change aliases in a view, your stored proc will return the changed name, assuming that you are working with SELECT * statements. This is consistent for all stored proc based on a particular view.|||You may want to have a look at extended properties
(sp_addextendedproperty, sp_updateextendedproperty, sp_dropextendedproperty).

It will not let you use the alias'es directly, but you do not have to come up with tables/functions etc to utilize them.

To use them you must (by code if you can, use syscomments or sqldmo) regenerate alll ddl's wher ethey are referenced (sysdepends, sysreferences).

not a small task...

Originally posted by durgadevi_n
Hi,
I want help regarding the following scenario...
My scenario is ...
I want to give description for each field somewhere in the database..
such that i should use that description as alias name in the SQL queries or Stored procedures...
For example...
Table : 'Table1'

Clumns Description

Field1 xxx
Field2 yyy

Query : Select Field1 as xxx , Field2 as yyy from Table1.

Mr requirement...
1.I want to specify tag or description for each field
2. if i change the description 'xxx' as 'x1x1x1',it should be automatically updated in the Query,Views,Storedproc.. wherever the table and the fields are referred.

can any one help me?.

No comments:

Post a Comment