Shetty's
Shetty's

Reputation: 617

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

Upvotes: 3

Views: 7366

Answers (2)

StuartLC
StuartLC

Reputation: 107267

It's as simple as:

ALTER VIEW V1 AS
  SELECT EMP_ID,NAME, SALARY WHERE SALARY > 10000;

Upvotes: 5

JeffUK
JeffUK

Reputation: 4241

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.

Upvotes: 1

Related Questions