Sp_Rename -->Table --> inside a View

Can I use Sp_Rename (or similar) to rename a -->Table   inside a View?

I Know:
I can go to design of the View and deal with it there or do a script Alter View

Because it would make my job very easy if I changed a table name to just use similar SQL to below to rename the table inside the view.

SQL I use to rename a table or column inside a table or view

sp_rename  @objname = 'tbl_a_Test_02' ,
                    @newname = 'tbl_a_Test_01'  ,
                    @objtype = 'OBJECT'

sp_rename  @objname = 'tbl_a_Test_01.Test_MyPay' ,
                    @newname = 'Test_Pay'  ,
                    @objtype = 'COLUMN'
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
>rename a -->Table   inside a View?
No, but you can use ALTER VIEW repeating the current view but with the new table name.  

Not sure why this would not be considered easy.  All you really need to do is use SSMS to script out the CREATE TABLE statement or go into your source control and find the object, change the CREATE to ALTER, change the table/column/whatever name, and execute.  Dilly dilly.
Mark WillsTopic AdvisorCommented:

Well, you *might* get away with it but wont help you in the end

From https://docs.microsoft.com/en-us/sql/relational-databases/system-stored-procedures/sp-rename-transact-sql 
Renaming a stored procedure, function, view, or trigger will not change the name of the corresponding object either in the definition column of the sys.sql_modules catalog view or obtained using the OBJECT_DEFINITION built-in function. Therefore, we recommend that sp_rename not be used to rename these object types. Instead, drop and re-create the object with its new name.

Renaming an object such as a table or column will not automatically rename references to that object. You must modify any objects that reference the renamed object manually. For example, if you rename a table column and that column is referenced in a trigger, you must modify the trigger to reflect the new column name. Use sys.sql_expression_dependencies to list dependencies on the object before renaming it.

You might want to investigate DDL triggers on RENAME to help automate the process.... But, it will take a lot of work (you dont have inserted or deleted like a DML trigger) : https://docs.microsoft.com/en-us/sql/relational-databases/triggers/ddl-triggers
Scott PletcherSenior DBACommented:
No, you can't.  Keep in mind that SQL must parse and form an execution plan for the query or view before it runs.  So the code can't dynamically change itself, or that would invalidate the query plan.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
LJGAuthor Commented:
Thanks for the answers.  I was hoping I was missing something, but I guess not.

I would like to share the points with all 3 of you, but apparently you can't do that now.

The site is going down hill.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.