Click here to Skip to main content
15,897,226 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hi ,
Can anyone help me with the query to get table name,column name , column datatype , isprimary etc in single row .

for eg:
My output of employee table with Columns E_Id,E_Name,E_City should be as below

--------------------------------------------------------------------------------------------------
TabName ColumnName datatype isprimary Columnname datatype isprimary Columnname datatype iprimary

Employee - E_Id - int - S - E_Name - varchar - N - E_City - varchar - N


--------------------------------------------------------------------------------------------------
Posted
Updated 7-Feb-14 0:28am
v3

Take a look at this thread's accepted answer ;)
http://stackoverflow.com/questions/10784369/to-get-table-details[^]
 
Share this answer
 
Comments
MurugappanCTS 7-Feb-14 6:42am    
this is not in my expected form . I expect one row for a single table detail not in multiple rows ??
Ahmed Bensaid 7-Feb-14 8:25am    
In my answer you have the solution. You just have to adapt it a little. CodeProject is not there to do your work for you ...
MurugappanCTS 7-Feb-14 8:35am    
Boss Already i have taken the solution which i want with the help of above example . but i am unable to use pivot.to turn into a single row
Ahmed Bensaid 7-Feb-14 9:27am    
http://stackoverflow.com/questions/17195709/display-multiple-rows-and-column-values-into-a-single-row-multiple-column-value
chage your table name and column name

SQL
select t1.user_id,t1.DATA_TYPE,t1.IS_NULLABLE,t2.name,t2.DATA_TYPE,t2.IS_NULLABLE,t3.city,t3.DATA_TYPE,t3.IS_NULLABLE from
(select  a.user_id ,b.DATA_TYPE,b.IS_NULLABLE from  tbl_user_registration as a left join INFORMATION_SCHEMA.COLUMNS as b  on  b.TABLE_NAME='tbl_user_registration' and b.COLUMN_NAME='user_id')as t1,

(select  a.user_id,a.name ,b.DATA_TYPE,b.IS_NULLABLE from  tbl_user_registration as a left join INFORMATION_SCHEMA.COLUMNS as b  on  b.TABLE_NAME='tbl_user_registration' and b.COLUMN_NAME='name') as t2,

(select a.user_id, a.city ,b.DATA_TYPE,b.IS_NULLABLE from  tbl_user_registration as a left join INFORMATION_SCHEMA.COLUMNS as b  on  b.TABLE_NAME='tbl_user_registration' and b.COLUMN_NAME='city') as t3  where t1.user_id=t2.user_id and t1.user_id=t3.user_id



you may get ideas
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900