Solved

Delete a SQL VIEW Object

Posted on 2010-09-12
7
315 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

762 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now