ahmed elbarbary

ahmed elbarbary

  • 1.2k
  • 713
  • 28.6k

How to separate value exist on temp table dynamically separa

Mar 26 2020 6:54 AM
problem

How to separate value exist on temp table dynamically separated by comma ?

i work on sql server 2012 i need to separate field TeamName by comma

teamname ,teamname+'Date'

i need to loop to teamname filed in tmp table #Teams then separate by comma and every field will be next field + 'Date'

really #temp table #teams every time changed so i dont have static data so i need any way dynamically sepatae field

and second will be field+date

 i need result as
 Package,PackageDate,Parametric,ParametricDate,Scribing,ScribingDate,Lifecycle,LifecycleDate

  1. CREATE TABLE #Teams  
  2. (  
  3. TeamId int,  
  4. TeamName  nvarchar(200)  
  5. )  
  6. insert into #Teams(TeamId,TeamName) values  
  7.  (1,'Package'),  
  8.  (2,'Parametric'),  
  9.  (3,'Scribing'),  
  10.  (4,'Lifecycle'

Answers (1)