| Author |
Query to display fiels names and types ?
|
|
| John Jasper 2005-09-28, 7:23 am |
| 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
| |
| Uri Dimant 2005-09-28, 9:23 am |
| 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
| |
| Nik Marshall-Blank \(delete fcom for my email addr 2005-09-28, 9:23 am |
| 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
| |
| John Jasper 2005-09-29, 3:23 am |
| 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...
>
>
>
| |
| John Jasper 2005-09-29, 3:23 am |
| 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...
>
>
>
|
|
|
|