MSSql
Nov. 3, 2014, 11:09 a.m.
Birden Fazla Satırı Tek Satırda Gösterme:
Declare @VisitId int
SET @VisitId = 0
SELECT CV.Id , CD.Name AS ConsultationNames
INTO #TmpTable1
FROM Sys_ConsultationVisit AS CV
LEFT JOIN Sys_ConsultationVisitDiagnostic ON Sys_ConsultationVisitDiagnostic.VisitId = CV.Id
LEFT JOIN Sys_ConsultationDiagnostic AS CD ON CD.Id = Sys_ConsultationVisitDiagnostic.DiagnosticId
WHERE @VisitId = 0 OR @VisitId = CV.Id
SELECT DISTINCT tt2.Id,
substring(
(
SELECT ' , '+tt1.ConsultationNames AS [text()]
FROM #TmpTable1 tt1
WHERE tt1.Id = tt2.Id
ORDER BY tt1.Id
FOR XML PATH ('')
), 3, 1000) As Certificates
INTO #tmpCertificateTable
FROM #TmpTable1 tt2
SELECT * FROM #tmpCertificateTable
DROP TABLE #TmpTable1
DROP TABLE #tmpCertificateTable
Clean Buffer:
DBCC FREEPROCCACHE
DBCC DROPCLEANBUFFERS