Drop Table

Support Forum for database administrators and web based access to important newsgroups related to databases
Register on Database Support Forum Edit your profileCalendarFind other Database Support forum membersFrequently Asked QuestionsSearch this forum -> 
For Database admins: Free Database-related Magazines Now Free shipping to Texas


Post New Thread










Thread
Author

Query to display fiels names and types ?
Can anyone help me with a query which will display each filed name from a
table along with the type of field and length ?  I have tried to google  the
question with no luck

Thanks

John Jasper

Report this thread to moderator Post Follow-up to this message
Old Post
John Jasper
09-28-05 12:23 PM


Re: Query to display fiels names and types ?
John
select ordinal_position 'Seq',
cast(column_name as varchar(40)) 'Column',
 isnull(character_max
imum_length, numeric_precision) 'Size',
cast(data_type   as varchar(12)) 'Type'
from   information_schema.columns
where  table_name = 'w_works'



"John Jasper" < JohnJasper@discussio
ns.microsoft.com> wrote in message
news:FA9148E1-E210-47F9-BE92- FF16B6FC260B@microso
ft.com...
> Can anyone help me with a query which will display each filed name from a
> table along with the type of field and length ?  I have tried to google
> the
> question with no luck
>
> Thanks
>
> John Jasper



Report this thread to moderator Post Follow-up to this message
Old Post
Uri Dimant
09-28-05 02:23 PM


Re: Query to display fiels names and types ?
Try this

DECLARE @ID INT
SELECT @ID = [id]
FROM [sysobjects]
WHERE [name] = 'Test'

SELECT A.[name], B.[name], A.[Length]
FROM [syscolumns] A
JOIN [systypes] B
ON A.[xtype ] = B.[xusertype]
WHERE A.[id] = @ID
ORDER BY [colid]

--
Nik Marshall-Blank MCSD/MCDBA

"John Jasper" < JohnJasper@discussio
ns.microsoft.com> wrote in message
news:FA9148E1-E210-47F9-BE92- FF16B6FC260B@microso
ft.com...
> Can anyone help me with a query which will display each filed name from a
> table along with the type of field and length ?  I have tried to google
> the
> question with no luck
>
> Thanks
>
> John Jasper



Report this thread to moderator Post Follow-up to this message
Old Post
Nik Marshall-Blank \(delete fcom for my email addr
09-28-05 02:23 PM


Re: Query to display fiels names and types ?
That did not work - did not get anything ((0 row(s) affected)

"Nik Marshall-Blank (delete fcom for my e" wrote:

> Try this
>
> DECLARE @ID INT
> SELECT @ID = [id]
> FROM [sysobjects]
> WHERE [name] = 'Test'
>
> SELECT A.[name], B.[name], A.[Length]
> FROM [syscolumns] A
> JOIN [systypes] B
> ON A.[xtype ] = B.[xusertype]
> WHERE A.[id] = @ID
> ORDER BY [colid]
>
> --
> Nik Marshall-Blank MCSD/MCDBA
>
> "John Jasper" < JohnJasper@discussio
ns.microsoft.com> wrote in message
> news:FA9148E1-E210-47F9-BE92- FF16B6FC260B@microso
ft.com... 
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
John Jasper
09-29-05 08:23 AM


Re: Query to display fiels names and types ?
Actually - that did work - I had originally used the name of the database
instead of a table - Thank-You

"Nik Marshall-Blank (delete fcom for my e" wrote:

> Try this
>
> DECLARE @ID INT
> SELECT @ID = [id]
> FROM [sysobjects]
> WHERE [name] = 'Test'
>
> SELECT A.[name], B.[name], A.[Length]
> FROM [syscolumns] A
> JOIN [systypes] B
> ON A.[xtype ] = B.[xusertype]
> WHERE A.[id] = @ID
> ORDER BY [colid]
>
> --
> Nik Marshall-Blank MCSD/MCDBA
>
> "John Jasper" < JohnJasper@discussio
ns.microsoft.com> wrote in message
> news:FA9148E1-E210-47F9-BE92- FF16B6FC260B@microso
ft.com... 
>
>
>

Report this thread to moderator Post Follow-up to this message
Old Post
John Jasper
09-29-05 08:23 AM


Sponsored Links





Last Thread Next Thread
Post New Thread

MS SQL Server archive

Show a Printable Version Email This Page to Someone! Receive updates to this thread
Microsoft SQL Server
Access database support
PostgreSQL Replication
SQL Server ODBC
FoxPro Support
PostgreSQL pgAdmin
SQL Server Clustering
MySQL ODBC
Web Applications with dBASE
SQL Server CE
MySQL++
Sybase Database Support
MS SQL Full Text Search
PostgreSQL Administration
SQL Anywhere support
DB2 UDB Database
Paradox Database Support
Filemaker Database
Berkley DB
SQL 2000/2000i database
ASE Database
Forum Jump:
All times are GMT. The time now is 01:28 PM.

 
Mobile devices forum | Database support forum archive




Copyrights DropTable.com Database Support Forum 2004 - 2006