Wednesday, March 28, 2012

Renameing a table

If the name of a database table no longer makes sense is there a way to
refer to it by another name, like an alias? Or would this be a view?
The database has been around awhile and there is lots of data and code
refering to the table, but it is confusing always having to translate the
table name to the new meaning.
Thanks
You can rename it with sp_rename. If you have a lot of code that refers to
the old name, though, this will break your code. In that case, you can
create a view with the new name and then you have both.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"Craig" <NoSpam@.hotmail.com> wrote in message
news:eboL23C0FHA.3720@.TK2MSFTNGP14.phx.gbl...
If the name of a database table no longer makes sense is there a way to
refer to it by another name, like an alias? Or would this be a view?
The database has been around awhile and there is lots of data and code
refering to the table, but it is confusing always having to translate the
table name to the new meaning.
Thanks
|||... and in SQL Server 2005 you will have synonyms.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23HnJ98C0FHA.3300@.TK2MSFTNGP15.phx.gbl...
> You can rename it with sp_rename. If you have a lot of code that refers to
> the old name, though, this will break your code. In that case, you can
> create a view with the new name and then you have both.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> .
> "Craig" <NoSpam@.hotmail.com> wrote in message
> news:eboL23C0FHA.3720@.TK2MSFTNGP14.phx.gbl...
> If the name of a database table no longer makes sense is there a way to
> refer to it by another name, like an alias? Or would this be a view?
> The database has been around awhile and there is lots of data and code
> refering to the table, but it is confusing always having to translate the
> table name to the new meaning.
>
> Thanks
>
>
|||Long overdue, IMHO. :-)
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:%23g7NIxI0FHA.2924@.TK2MSFTNGP15.phx.gbl...
... and in SQL Server 2005 you will have synonyms.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Tom Moreau" <tom@.dont.spam.me.cips.ca> wrote in message
news:%23HnJ98C0FHA.3300@.TK2MSFTNGP15.phx.gbl...
> You can rename it with sp_rename. If you have a lot of code that refers
> to
> the old name, though, this will break your code. In that case, you can
> create a view with the new name and then you have both.
> --
> Tom
> ----
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> .
> "Craig" <NoSpam@.hotmail.com> wrote in message
> news:eboL23C0FHA.3720@.TK2MSFTNGP14.phx.gbl...
> If the name of a database table no longer makes sense is there a way to
> refer to it by another name, like an alias? Or would this be a view?
> The database has been around awhile and there is lots of data and code
> refering to the table, but it is confusing always having to translate the
> table name to the new meaning.
>
> Thanks
>
>

No comments:

Post a Comment