SQL SERVER – Rename View

There are two different ways one can rename view in SQL Server. Let us see in today’s blog post how to rename view. 1) SSMS 2) T-SQL

SQL SERVER - Rename View renameview-800x643

Method 1 – SSMS

This is the easiest and most people do use this method. First, go to Object Explorer, expand the databases node and further expand your preferred database. Next, select the section Views and right-click on the view which you want to rename.

SQL SERVER - Rename View renameview

Once you write click on the view, now you select the option rename. In the next step, you can enter the name of the view and it will be done!

Method 2 – TSQL

This is another method but it is not my preferred method.

EXEC sp_rename @objname = 'schema.oldviewname',  @newname = 'newviewname';

That’s it. Once you run the script it will rename the old view. You may see the warning after you run the script above. You will have to replace now the old name with a new name in your queries and stored procedure.

I personally do not like this method. If you have to use this method, I suggest you just drop the older view and recreate the new view. I have found that to be more error-free and if there are any dependencies, I usually come to know early.

If you liked this blog, please do not forget to subscribe to my YouTube Channel – SQL in Sixty Seconds.

Here are my few recent videos and I would like to know what is your feedback about them.

Reference: Pinal Dave (http://blog.SQLAuthority.com)

SQL Scripts, SQL Server, SQL View
Previous Post
SQL SERVER – Logs are Full and Can’t Switch Recovery Models
Next Post
SQL SERVER – Available Free Space in Data and Log File

Related Posts

Leave a Reply