Click here to Skip to main content
15,886,701 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
i want to write a select Query which select all Tables and Columns of Data Base. which will work any version of sql server(2000,2005,2008) data base.i wrote one Qyery:-
SQL
SELECT t.name AS table_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID


but it not work in sql server 2005....
Posted
Comments
OriginalGriff 4-Jun-12 4:40am    
When you say "it not work" what do you mean? Did it error? Or give you odd data?

You could just use:
SQL
SELECT TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS
 
Share this answer
 
Comments
Rajesh Anuhya 4-Jun-12 5:00am    
+5 Agreed!
VJ Reddy 4-Jun-12 5:19am    
5ed!
Use Information_schema views as per the OriginalGriff answer, in addition to go through the below link for more information
Here[^]

Thanks
--RA
 
Share this answer
 

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