C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




sql query


Posted Date: 05 Sep 2008      Total Responses: 7

Posted By: Rakesh Thakur       Member Level: Silver     Points: 1


hi all,
can any body help me in writing the query in sql,which return the fields name and the datatType of the table.




Responses

Author: ANIL PANDEY    05 Sep 2008Member Level: DiamondRating:     Points: 3
hello,


u can use the following command to get the details

exec sp_help tabname

Regards
Anil Pandey



Author: Priya    05 Sep 2008Member Level: SilverRating:     Points: 2

Try this code using dataset, it will display the column name and the datatype.

Dim adapter As System.Data.SqlClient.SqlDataAdapter
' set up your adapter, select-query the table you want to insert

Dim ds As DataSet
adapter.Fill(ds)

Dim dt As DataColumn
For Each dt In ds.Tables(0).Columns
Response.Write(dt.ColumnName)
Response.Write(dt.DataType.ToString() + "<br>")
Next

Hope this helps



Author: Lakhan Pal    05 Sep 2008Member Level: GoldRating:     Points: 3
select column_name, data_type, character_maximum_length from information_schema.columns
where table_name = 'myTable'

Try This..
This will give you the required Output



Author: @@@ Hyderabadi Biryani @@@    05 Sep 2008Member Level: DiamondRating:     Points: 3
Hi

Check out the below query

Select COLUMN_NAME
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH,
NUMERIC_PRECISION,
NUMERIC_SCALE
From Information_Schema.Columns
Where Table_Name = 'table_name'



Thanks -- Vj
http://dotnetvj.blogspot.com



Author: Suba Ganesh    06 Sep 2008Member Level: SilverRating:     Points: 1
sp_help tablename


Author: Suba Ganesh    06 Sep 2008Member Level: SilverRating:     Points: 1




sue this

query


sp_help tablename


Author: Ashwini Rupert    10 Sep 2008Member Level: DiamondRating:     Points: 2
Hi,

The following query returns all the information about the database

select * from information_schema.columns

To get only the information you require

select column_name, data_type from information_schema.columns

Regards,
Ashwini


Post Reply
You must Sign In to post a response.
Next : TOP function
Previous : hi frnds please help me its urgent
Return to Discussion Forum
Post New Message
Category: SQL Server

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use