Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Statement to select field names

Status
Not open for further replies.

ThinPeter

Programmer
Dec 8, 2004
3
US
I am a MySQL administrator, attempting to quickly (and unexpectedly) move a MySQL db to a SQL Server 2000 db. Databases have been moved and are functioning correctly. Now, the problem is with the software and some mysql statements that are not compatible with SQL Server

1 (and most importantly). Is there a way to return column names from a given table? MySQL uses SHOW FIELDS, or DESCRIBE TABLE; Anything in SQL that would accomplish the same thing?

2. Is there any online documentation that you would recommend for a MySQL to SQL Server migration?

Thanks for the help.



- HEY, Peter man
 
This will work for you.
Code:
select *
from INFORMATION_SCHEMA.columns
where TABLE_NAME = '{Table_Name}'

Denny

--Anything is possible. All it takes is a little research. (Me)

[noevil]
(My very old site)
 
Code:
select c.name from sysobjects t inner join syscolumns c on t.id=c.id where t.name='MyTableName' and t.xtype='u'
that will get you the coluumn names for a given table just replace mytable name with your table name
 
SQL In A Nutshell BY Kevin Kline with Daniel Kline

This O'reilly book has the syntax for ANSI SQL, SQL Server, MySQL, Oracle and PostgreSQL. A great reference for when you are converting from one to the other.

Questions about posting. See faq183-874
Click here to learn Ways to help with Tsunami Relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top