Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"No column was specified" Error 1

Status
Not open for further replies.
Oct 11, 2006
300
US
Hi,

I get the error:

No column was specified for column 4 of 'organization'.

in the following code:

Code:
select * from 
( select 1 as depth,
         emp,
         boss,
         cast(rtrim(emp) as varchar (400))	
    from tree
  where boss is null
  union all
  select a.depth + 1 as depth,
         b.emp,
         b.boss,
         cast (a.chain + ', ' + rtrim(b.emp) as varchar(400))
    from organization a
   inner join tree b
      on a.employee = b.boss
) organization

Table structure for Organization is:

Code:
CREATE TABLE Organization
(
	depth integer,
	employee varchar(20),
	boss varchar(20),
	chain varchar(20)
)

Table Structure for Tree is:

Code:
create table tree
(emp Char(10) Not Null,
Boss Char(10))
 
you didn't gave name of that column:
Code:
 cast(rtrim(emp) as varchar (400))

try with
Code:
 cast(rtrim(emp) as varchar (400))  AS Emp

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
MVP VFP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top