1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
DECLARE @Chaine varchar(max)
DECLARE @ID int
DECLARE @ID1 int
SET @Chaine=''
DECLARE @nouvChaine varchar(max)
SET @nouvChaine=''
DECLARE @docType Varchar(40)
DECLARE @docType1 Varchar(40)
DECLARE #Doctype CURSOR
FOR SELECT DISTINCT
T1.ID AS ID,
T1.DOCUMENTTYPE
FROM T1;
OPEN #Doctype
FETCH #Doctype INTO @ID,@docType
FETCH #Doctype INTO @ID1,@docType1
WHILE(@@fetch_status=0)
BEGIN
WHILE (@ID1=@ID)
BEGIN
SET @Chaine=@Chaine+@docType+'\''+@docType1
FETCH #Doctype INTO @ID1,@docType1
END
INSERT DOCTYPETABLE VALUES(@ID,substring(@Chaine,0,len(@Chaine)))
SET @ID=@ID1
SET @Chaine=@docType1
SET @docType=''
FETCH #Doctype INTO @ID1,@docType1
if(@@fetch_status<>0)
BEGIN
--ici je fait l''insertion de resultatde concaténation dans un nouveau tableau
INSERT DOCTYPETABLE VALUES(@ID,substring(@Chaine,0,len(@Chaine)))
END
END
CLOSE #Doctype
DEALLOCATE #Doctype |
Partager