Pages

Sunday, March 17, 2013

Merubah hasil select Banyak Baris menjadi satu baris Record


Code Standar function Select yang menghasilkan data dalam bentuk baris record yang banyak :


select Emplname  from mst_employee  where section='system'


Code  untuk membuat hasil select menjadi  satu record / satu baris :

declare @teks varchar(2000)
   select @teks = coalesce(@teks+',','')+ cast(Emplname as varchar(50))from mst_employee
   where  section='system'
   select @teks Nama_Karyawan

1 comment: