Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Help with coverting query to a view

Author  Topic 

wishmaker
Starting Member

7 Posts

Posted - 2015-01-23 : 11:13:01
I getting an error when trying to convert the follwing into a view. I can't take the credit for the code as I cpoied it from with a program.

Your help will be greatly appreciatted. Thank you John

Create view vwMAW_KnowledgeDB AS
Select * from don0001
left join (select donclass.donor from donclass where classification = 9 and code in ('KB')) inc0 on inc0.donor = don0001.donor where inc0.donor is not null


quote:
Error; Msg 4506, Level 16, State 1, Procedure vwMAW_KnowledgeDB, Line 2
Column names in each view or function must be unique. Column name 'donor' in view or function 'vwMAW_KnowledgeDB' is specified more than once.

Bustaz Kool
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2015-01-23 : 11:39:02
[SOAPBOX]
SELECT * <==== NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW NEVER DO THIS IN A VIEW (But I repeat myself...)
[/SOAPBOX]

Since you are not naming the columns, there is at least one column in don001 that has the same name as a column in donclass. In an independent SELECT statement this is legal but not in a View.



No amount of belief makes something a fact. -James Randi
Go to Top of Page
   

- Advertisement -