473,624 Members | 2,439 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 5466
You have to join both catalog views by object_id:

SELECT SCHEMA_NAME(T.s chema_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_SCH EMA.COLUMNS
WHERE table_name = 'MyTableName';
HTH,

Plamen Ratchev
http://www.SQLStudio.com
Apr 2 '08 #2
ro******@hotmai l.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******@hotmai l.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
1486
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 this list to find the best player at defending, attacking, midfield and goalkeeping. However there is more than one defender per team so I therefore need it to find the next best player.
12
29063
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, listFunction(SELECT name FROM names WHERE name_parent=p.id) AS 'nameList' FROM projects AS p
8
4322
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. Basically I want to say: If fk_ID is in list then do these statements to that record
4
4712
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 top row, and the 2nd header row would come from the 2nd datatable? In this case, i guess i would have to add a row manually above the header row (2nd dataset) which is the set of 1st data? if someone has ideas, code explaining it would be very...
1
5364
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 column for the data that was passed. In other words, the update may only have one or two of the parameters that was originally provided in the insert. Therefore, I do not want to update the columns that did not change. What is the proper way to...
2
24760
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 <tableset = '' where IS NULL But because there are lots of columns this is pretty much work, also there are multiple tables.
2
3504
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 measurements are added every day. So, I have to set some extra columns in advance, so space is available whenever is needed and the client doesn't have to modify the structure in SQL server.
2
3704
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 without using the wizard, and it will not "drop-down" - the list is horizantal. I don't see a variable to set to change that. I tried the listbox in the toolbox, and it is also horizantal (tried that first). The behavior I want is to list,...
0
8240
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7168
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6111
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5565
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4177
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.