Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Update View in SQL Server 2005

I want to update the existing view without dropping it, can you just provide me the syntax how to do it..?

Existing view:

CREATE VIEW V1 AS SELECT EMP_ID,NAME FROM EMP_TABLE

I want to update V1 as:

SELECT EMP_ID,NAME, SALARY WHERE SALARY>10000
like image 670
Shetty's Avatar asked Apr 29 '26 05:04

Shetty's


2 Answers

It's as simple as:

ALTER VIEW V1 AS
  SELECT EMP_ID,NAME, SALARY WHERE SALARY > 10000;
like image 74
StuartLC Avatar answered May 02 '26 01:05

StuartLC


If you forget this in the future, you can always right click on the view in SQL Server Management Studio and select 'Modify' this will give you the current query, with the correct syntax for altering it.

like image 27
JeffUK Avatar answered May 02 '26 00:05

JeffUK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!