473,499 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

List Columns in a Table in SQL 2005

Hi, I know sys.tables and sys.columns gives me a list of tables and
columns in a SQL 2005 database.

How can I list Columns in a specific Table please?

Thanks in advance,
Ronny
Apr 2 '08 #1
3 5457
You have to join both catalog views by object_id:

SELECT SCHEMA_NAME(T.schema_id) AS 'Schema',
T.name AS 'Table Name',
C.name AS 'Column Name'
FROM sys.tables AS T
JOIN sys.columns AS C
ON T.object_id = C.object_id
WHERE T.type = 'U'
AND T.name = 'MyTableName';

Or you can use:

SELECT table_schema,
table_name,
column_name
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = 'MyTableName';
HTH,

Plamen Ratchev
http://www.SQLStudio.com
Apr 2 '08 #2
ro******@hotmail.co.uk wrote:
Hi, I know sys.tables and sys.columns gives me a list of tables and
columns in a SQL 2005 database.

How can I list Columns in a specific Table please?

Thanks in advance,
Ronny
desc tablename
Apr 2 '08 #3
lark wrote:
ro******@hotmail.co.uk wrote:
>Hi, I know sys.tables and sys.columns gives me a list of tables and
columns in a SQL 2005 database.

How can I list Columns in a specific Table please?

Thanks in advance,
Ronny
desc tablename
scratch that. it doesn't work in ms sqlserver.
Apr 2 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
1476
by: Ben | last post by:
Hi In a list I have a number of soccer players. Each player has a different rating for attacking, defending, midfield fitness and goalkeeping. I have devised a while loop that goes through...
12
29051
by: insomniux | last post by:
Hi, I'n in an environment where I cannot make stored procedures. Now I need to make a query with a subquery in the SELECT part which gives a comma separated list of results: SELECT p.id,...
8
4317
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
4
4701
by: Mortar | last post by:
i need a datagrid with 2 header columns. The top one might have 1 column spanning 5 columns of the header row below it. what is the best way to do this? Could i have 2 datatables...1 filling the...
1
5356
by: binder | last post by:
I have a stored procedure that inserts values into five columns of a table. I need another stored procedure that will allow the user to pass one or more of those parameters and update only the...
2
24721
by: BF | last post by:
Hi, I have some tables where I import data in, lots of field have gotten a NULL value which the application can not handle. Now can I replace each NULL value with '' in a columns with: update...
2
3496
by: Nacho | last post by:
Hi, I'm designing a new database and I have a doubt in which surely you can help me. I'm storing in this database historical data of some measurements and the system in constantly growing, new...
2
3694
by: Doug | last post by:
Hi, I can't figure out how to create a drop-down list box. The help file says it exists. The icon in the help file matches the combobox in the toolbox. I tried using a combox box, both with and...
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7012
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5479
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3105
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.