Solved

Delete a SQL VIEW Object

Posted on 2010-09-12
7
318 Views
Last Modified: 2012-05-10
How do i Delete a SQL View object once I create the view.

Once I run this query and it creates the view:

USE DATBS_A
GO
CREATE VIEW SUMMARY AS
SELECT person_no, assignment_no, start_date
FROM summary
WHERE role = 'Worker'

How can i remove the view so I can execute the same statement?
0
Comment
Question by:TAMSCODAN
7 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33657436
DROP VIEW SUMMARY
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33657438
Or if all you want to do is modify it then:

ALTER VIEW SUMMARY AS
...
0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 33657472

USE DATBS_A
GO
DROP VIEW SUMMARY
GO
CREATE VIEW SUMMARY AS
SELECT person_no, assignment_no, start_date
FROM summary
WHERE role = 'Worker'


When i do this now it looks like the query is running ok, however I am not getting any results, wne I run the view over
0
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
LVL 13

Expert Comment

by:p_nuts
ID: 33658264
what is the difference between the new and the old view
0
 
LVL 3

Author Comment

by:TAMSCODAN
ID: 33658340
Basically that was one of my requirements to ensure it checks to see if there is an old and update it with the new. I got most of it done but dont seem to figure out why my data is not appearing. It doesnt appear at all, but only when i run hte SELECT statement by itself. if i run the entire thing, Query was done succesfully however i dont see the results.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 33658485
There seems to be some confusion here:
CREATE VIEW: Creates the view it does not execute it.  In order to execute it you need to do something like this:
SELECT person_no, assignment_no, start_date
FROM SUMMARY
0
 
LVL 9

Accepted Solution

by:
auke_t earned 500 total points
ID: 33659882
The view seems to have the same name as the table. This isn't possible!

CREATE VIEW
vw_SUMMARY
AS
SELECT person_no, assignment_no, start_date
FROM summary
WHERE role = 'Worker'

--and if you want to remove the view again:

drop view vw_summary
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question