title: row wise concatenate with dynamic column in sql?
body: <p>I need to concatenate row wise columns. I have done it but in my table columns are static, but in my requirement columns will be dynamic.</p>
  
  <pre><code>CREATE TABLE #TEMP
  (
  ID INT 
  ,Name VARCHAR (100)
  ,SNO INT 
  ,SNO1 INT
  ,SNO2 INT
  )
  
  INSERT INTO #TEMP (ID ,Name,SNO,SNO1,SNO2)
  VALUES (1,'SAS',1,2,4),(2,'RAR',5,2,5),(3,'SJS',6,8,6)
  
  SELECT * FROM #TEMP
  
  ID  Name    SNO SNO1 SNO2
  1   SAS      1   2     4
  2   RAR      5   2     5
  3   SJS      6   8     6
  
  SELECT ID,NAME,SNO,(SNO+SNO1)AS SNO1,(SNO+SNO1+SNO2)AS SNO2 FROM #TEMP
  
  ID  NAME    SNO   SNO1     SNO2
  1   SAS     1       3         7
  2   RAR     5       7         12
  3   SJS     6       14        20
  </code></pre>