Declare @PayStr Varchar(200)Set @PayStr = ''Select @PayStr = @PayStr + ',' + Cast(DetailID as Varchar(20)) From GHBaseDB.dbo.tPubClass_Detail B where ClassID= 6512Select @PayStr