473,326 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Help with getting table information from sqlserver

I am new to using sqlserver and have been given the task to get the column
name, data type and the description from a given table and put this into
another table. Can this be done?

Thanks in advance.

Jeff Magouirk
Jul 20 '05 #1
2 1736

"Jeff Magouirk" <ma*******@njc.org> wrote in message
news:10*************@corp.supernews.com...
I am new to using sqlserver and have been given the task to get the column
name, data type and the description from a given table and put this into
another table. Can this be done?

Thanks in advance.

Jeff Magouirk


You can get the column names and data types from INFORMATION_SCHEMA.COLUMNS:

select COLUMN_NAME, DATA_TYPE
from INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = 'MyTable'

I'm not sure what you mean by the "description" of a table. Assuming you
mean an extended property of some sort, you would need to look at
::fn_listextendedproperty(). But I'm not sure what the point is of storing
this information in your own table when it's already in the system tables
and automatically updated there for you - it might be easier to simply
retrieve it when you need it.

Simon
Jul 20 '05 #2
<snip>

Thanks for the code. What I mean by description is when you open the design
table window, there is a place that you can put the description of the
column on. I am wondering if I can get that also.

Thanks,

Jeff



Yes, that's an extended property - Enterprise Manager creates an extended
property on the column, called "MS_Description". You can get the values like
this:

SELECT objname as 'Column', value as 'Description'

FROM ::fn_listextendedproperty (NULL, 'user', 'dbo', 'table', 'MyTable',
'column', default)

where name = 'MS_Description'

Simon


Jul 20 '05 #3

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

Similar topics

12
by: J. Hall | last post by:
Guys, Got this query... --------------------------- SELECT TOP 5 Tbl_admin_hotels.HotelName, (SELECT COUNT(Tbl_marketing_history.HotelID) FROM Tbl_marketing_history WHERE...
2
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message....
3
by: Jason Manfield | last post by:
Given a table name (e.g. CUSTOMERS), how do I get column names of the table and the data types of the columns the table has? I am using SQLServer and would like to get that info from my C# code.
5
by: EMW | last post by:
Hi, Can someone please look at this code and tell me why I get an exception error on the last line: For aa = 0 To ds.Tables(0).Columns.Count - 1 dbColumn = New SQLDMO.Column dbColumn.Name =...
7
by: Niyazi | last post by:
Hi, I am developing small insurance application using VB.NET and SQL server 2000. My tables in SQL server are: tbl_Customer (stores the custmer information) tbl_CustImage ...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
5
by: Glen Buell | last post by:
Hi all, I have a major problem with my ASP.NET website and it's SQL Server 2005 Express database, and I'm wondering if anyone could help me out with it. This site is on a webhost...
0
by: TG | last post by:
Hi! Once again I have hit a brick wall here. I have a combobox in which the user types the server name and then clicks on button 'CONNECT' to populate the next combobox which contains all the...
2
by: Dinesh | last post by:
Hi experts, I am working on SQL Server 2005. Now i have to write a query which will extract some information from a table. My main table is having few columns supose 3 columns. EmpID ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.