Query genus required

  • Thread starter Thread starter Ivan Jericevich
  • Start date Start date
I

Ivan Jericevich

In my code below the result returns two rows. This particular Tenant occupys
2 Units. How do I join the two rows to give me "Unit1 and Unit4"

ALTER PROCEDURE dbo.getUnitNumbers
@TenantID int,

@UnitNumber varchar(50) OUTPUT

as

SELECT TOP (8) @UnitNumber = UnitNumber

FROM Area

WHERE (TenantID = @TenantID)

ORDER BY UnitNumber
 
I don't think you can do that with a single SELECT query. It may be
better to count the number of rows returned, and if it's more than one
loop through them and concatenate the string yourself.

Carol
 
Thanks Carol, I had the assumption it would be something like this. But I
simply don't know how to ask it to just that.
 
Try posting this to microsoft.public.sqlserver.programming.
I think they will know how to do this, and if it definitely
can't be done, they'll tell you that, too. I'm assuming this
is SQLServer? I would post the version you are using, as
well as the DDL for creating the tables, or the table
structures.

Robin S.
 
Back
Top