title: Comma Separated List of all columns in the Database (Tablename | Column_names...)
body: <p>In SQL Server, I would like see Table_Name and all the Columns associated with that Table_Name in a database. So the Output should look like this: </p>
  
  <pre><code>      TABLE_NAME     COLUMN_NAME 
  
     1. Employee       Employee-id, Lastname, Firstname, Title...........
     2. Orders         Orderid, Order-date, shipped-date, delivery-date.......
     3. Products       Product-id, Product-name, supplier-id, category-id.....
     4. Suppliers      Supplier-id, Company-name, contact-name.......
     5. ............................................................
     6. ...................................................
        (So on....)
  </code></pre>
  
  <p>Is it possible to get the above results with WHILE LOOP or any other way? If YES, could you post the code. </p>
  
  <p>Also, I tried to do this problem using a Temp Table:  </p>
  
  <pre><code> create table #hello
   (table_name1 Varchar(max))
    insert into #hello(table_name1)
    select table_name from information_schema.columns 
   GO
  
   create table #hello2
   (table_name2 varchar(max),column_name2 varchar(max))
    insert into #hello2(table_name2 ,column_name2)
    select table_name,column_name from information_schema.columns 
   GO
  
   select  a.table_name1,b.column_name from #hello a inner join
     information_schema.columns b
   on a.table_name1=b.table_name COLLATE Latin1_general_CI_AS
   order by table_name 
   GO      
  </code></pre>
  
  <p>I was successful in listing the columns Vertically but i couldn't get the comma separated list of columns.</p>