• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
sqlserver tutorial

SQL Server Tutorial

SQL Server Tutorial for Beginners

  • HOME
  • START HERE
  • BASICS
  • ADVANCED
    • Index
    • Views
    • Triggers
    • Stored Procedures
    • User-defined Functions
  • FUNCTIONS
Home / SQL Server Views / SQL Server Rename View

SQL Server Rename View

Learning Objective

The objective of this tutorial to teach you to rename a view in SQL Server Database.

Please note that renaming a view may result in failure for all the objects those are dependent on that view. These objects include triggers, user-defined functions, stored procedures, queries, other views, etc.

So, make sure that after renaming a view you need to update the new view name on these objects. So that the referencing objects are pointing toward the correct view.

 SQL Server rename view using Server Server Management Studio (SSMS)

In order to rename a view in SQL Server using SQL Server Management Studio, you need to perform the following steps.

First, in object explorer, expand the Databases, choose the database name which contains the view that contains the view that you want to rename and expands the Views folder.

Second, right-click on the view that you want to rename.

SQL Server Rename View
SQL Server Rename View

Third, enter the new name for the view and press enter.

SQL Server rename view using Transact-SQL

If you want to rename a view using SQL statement, you can use sp_rename stored procedure.

EXEC sp_rename
@objname = 'dbo.Vwemp',
@newname = 'Vwemp_details';

In this syntax,

@objname – You need to provide the view name using @objname which you want to rename. Note that you must need to provide schema name here along with view name.

@newname – The new name needs to specify here using @newname parameter. Note that you must not specify the schema name here.

Once you execute the sp_rename stored procedure, it returns the following message.

Caution: Changing any part of an object name could break scripts and stored procedures.

In this tutorial, you have learned how to rename a view in SQL Server database using SQL Server Management Studio(SSMS) and Transact-SQL.

Was this tutorial helpful?
YesNo
« Previous: SQL Server List Views
Check view definition :Next »

Primary Sidebar

DATA MANIPULATION

  • SELECT
  • SELECT TOP
  • SELECT DISTINCT
  • OFFSET FETCH
  • ORDER BY
  • GROUP BY
  • BETWEEN
  • LIKE
  • ALIAS
  • HAVING
  • AND
  • OR
  • IN
  • WHERE
  • SELECT INTO
  • INSERT
  • INSERT Multiple rows
  • INSERT INTO SELECT
  • UPDATE
  • DELETE
  • PRIMARY KEY
  • FOREIGN KEY
  • UNIQUE CONSTRAINT
  • NOT NULL CONSTRAINT
  • SUBQUERY
  • CORRELATED SUBQUERY
  • JOINS
  • CROSS JOIN
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL JOIN
  • SELF JOIN
  • UPDATE Join
  • CASE
  • COALESCE
  • NULL
  • NULLIF
  • UNION
  • INTERSECT
  • MERGE
  • EXCEPT
  • EXISTS
  • GROUPING SET
  • PIVOT
  • ROLLUP
  • CUBE

DATA DEFINITION

  • CREATE DATABASE
  • DROP DATABASE
  • CREATE SCHEMA
  • ALTER SCHEMA
  • DROP SCHEMA
  • CREATE TABLE
  • RENAME TABLE
  • DROP TABLE
  • TRUNCATE TABLE
  • IDENTITY column
  • Sequence
  • ALTER TABLE ADD Column
  • ALTER TABLE ALTER Column
  • ALTER TABLE DROP Column

Footer

About

SQLServerTutorial.org provides free tutorials and guide on SQL Server for Developers, Database Administrators, and Solution Architects who want to get started SQL Server quickly.

Recent Posts

  • SQL Server DROP VIEW
  • SQL Server Indexed View
  • Check view definition
  • SQL Server Rename View
  • SQL Server List Views

Quick Links

  • About
  • Contact Us
  • Privacy Policy
  • SQL Server Index
  • SQL Server Views
  • Terms of Use

Copyright © 2023 www.sqlservertutorial.org. All Rights Reserved.