我正在获取某些用户和组名的文件名。一世 希望不同行中的文件名位于同一行。
我的结果是:
2 group 2 file1 10
2 group 2 file2 10
我想要的是:
2 group 2 file1 10 file2 10
我的程序:
Alter PROCEDURE [dbo].[DisplayDetails]
@User_Id int,
@Group_Id int OUTPUT,
@Group_Name varchar(255) OUTPUT,
@No_of_flat_files int OUTPUT,
@Filename varchar(255) OUTPUT,
@No_of_records int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
select @Group_Id=Group_Id,
@Group_Name=Group_Name,
@No_of_flat_files=No_of_flat_files,@Filename=file_name,
@No_of_records=No_of_records from INPUT_FILES_updated
where file_sequence='1' and [User_Id]=@User_Id
union
select @Group_Id=Group_Id,
@Group_Name=Group_Name,
@No_of_flat_files=No_of_flat_files,@Filename=file_name,
@No_of_records=No_of_records from INPUT_FILES_updated
where file_sequence='2' and [User_Id]=@User_Id
union
select @Group_Id=Group_Id,
@Group_Name=Group_Name,
@No_of_flat_files=No_of_flat_files,@Filename=file_name,
@No_of_records=No_of_records from INPUT_FILES_updated
where file_sequence='3' and [User_Id]=@User_Id
union
select @Group_Id=Group_Id,
@Group_Name=Group_Name,
@No_of_flat_files=No_of_flat_files,@Filename=file_name,
@No_of_records=No_of_records from INPUT_FILES_updated
where file_sequence='4' and [User_Id]=@User_Id
RETURN
END
Declare @Group_I int ,@Group_Na varchar(50),@No_of_flat_fil int,
@Filena varchar(255) , @No_of_reco int
Execute [dbo].[DisplayDetails] @User_Id=2, @Group_Id=@Group_I output, @Group_Name=@Group_Na output,@No_of_flat_files=@No_of_flat_fil out,@Filename=@Filena out,@No_of_records=@No_of_reco
SELECT @Group_I,@Group_Na ,@No_of_flat_fil, @Filena, @No_of_reco