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
 can't create view

Author  Topic 

kifeda
Posting Yak Master

136 Posts

Posted - 2009-12-23 : 15:59:31
I'm stuck. I'm trying to create a view but MS SQL won't let me. I get an error when I try to build a view that says:
view definition includes no output columns or includes no items in the from clause

I don't know why I'm getting that error because I do have information in the from clause. Here is my view:

SELECT s.classname AS semester,
(SELECT COUNT(*)
FROM tblregistration g
WHERE g.intsemesterid = r.intsemesterid) AS semesterCount, p.classname AS program,
(SELECT COUNT(*)
FROM tblregistration g
WHERE g.intprogramid = r.intprogramid) AS ProgramCount, l.classname AS LEVEL,
(SELECT COUNT(*)
FROM tblregistration g
WHERE g.intlevelid = r.intlevelid) AS LevelCount, sl.classname sublevel,
(SELECT COUNT(*)
FROM tblregistration g
WHERE g.intsublevelid = r.intsublevelid) AS SubLevelCount, u.FirstName AS firstName, u.LastName AS lastName, u.birthday AS dateOfbirth,
u.healthFormdate AS healthDate, u.address AS address
FROM tblregistration r LEFT OUTER JOIN
Danceusers u ON u.userid = r.intuserId LEFT OUTER JOIN
classes s ON s.classID = r.intsemesterId LEFT OUTER JOIN
classes p ON p.classID = r.intprogramId LEFT OUTER JOIN
classes l ON l.classID = r.intlevelId LEFT OUTER JOIN
classes sl ON sl.classid = r.intsublevelid

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-12-23 : 16:19:51
The query is a little ugly but it should work. Post the entire CREATE VIEW statement you are trying.

Be One with the Optimizer
TG
Go to Top of Page

kifeda
Posting Yak Master

136 Posts

Posted - 2009-12-23 : 16:34:54
thats it. I just pasted it in
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-12-23 : 17:11:52
What happens when you run the statement without the CREATE VIEW part?

Be One with the Optimizer
TG
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2009-12-23 : 17:15:21
quote:
Originally posted by kifeda

thats it. I just pasted it in


I meant including the "create view". Just wanted to make sure you had the syntax correct...

Be One with the Optimizer
TG
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2009-12-23 : 17:28:37
Are you trying to create it from the view designer or from a new query window?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

"Let's begin with the premise that everything you've done up until this point is wrong."
Go to Top of Page
   

- Advertisement -