Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I already have a table EMP_DETAILS, which is containing (EMP_ID (Primary Key), FIRST_NAME, LAST_NAME, AGE, ADDRESS, SALARY, DEPT_ID (Foreign Key),
DELETE_DATE
).

I already created a View for the table, but when I created that table I missed one column (FIRST_NAME).

I want to add that column in this existing View with out drop this.
Posted
Comments
Richard Deeming 17-Dec-14 9:21am    
You have already posted this question, and received perfectly good answers:
http://www.codeproject.com/Questions/854038/How-to-add-a-column-in-a-existing-view-in-sql[^]
Bittu14 18-Dec-14 5:18am    
Yes. But I did not get any proper answer.
Richard Deeming 18-Dec-14 7:24am    
That is NOT an excuse to re-post your question.

Besides which, Mehdi Gholam's answer is perfectly valid and correct. You need to learn the syntax of the ALTER VIEW statement, which is documented in the link in that answer.
Bittu14 18-Dec-14 8:27am    
I already tried that alter it has shown some error which I was post.
Richard Deeming 18-Dec-14 9:19am    
Which DamithSL then answered in solution #2 - you are using the wrong product to manage a Microsoft SQL Server database.

That still doesn't give you an excuse to re-post the same question!

hi,

no need to drop
alter your view.
try this.

alter view view_name
as
change your query

execute the above after change.
might this help you.
 
Share this answer
 
Comments
Shweta N Mishra 17-Dec-14 9:12am    
+5
Bittu14 18-Dec-14 8:29am    
I already tried that one.

My query which I wrote :

ALTER VIEW BISA1.EMPLOYEE_DETAILS_VIEW AS
SELECT EMP_ID, FIRST_NAME, LAST_NAME, AGE, ADDRESS, SALARY, DEPT_ID
FROM EMP_DETAILS;


And it has shown some error:

SQL Error: ORA-00922: missing or invalid option
00922. 00000 - "missing or invalid option"
*Cause:
*Action:
Bittu14 18-Dec-14 8:30am    
Can you please let me know where is the actual problem.
mudgilsks 18-Dec-14 8:38am    
what is BISA1.EMPLOYEE_DETAILS_VIEW
use EMPLOYEE_DETAILS_VIEW only
Bittu14 18-Dec-14 9:03am    
Nothing leave it.
Step 1 : use sp_helptext to view the definition of the view.

step 2 : copy the definition of the view and paster it in the T-SQL window

step 3 : change the create view as Alter view and then add the new columns in the view, once the alteration in completed execute the query window. Then the definition of the view is updated.
 
Share this answer
 
what is BISA1.EMPLOYEE_DETAILS_VIEW
use EMPLOYEE_DETAILS_VIEW only
 
Share this answer
 
Comments
Bittu14 18-Dec-14 9:03am    
Yes, I tried that, but it has an error.
Bittu14 18-Dec-14 9:07am    
A red line has shown before the "AS" clause.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900