Drop Table
Support Forum for database administrators and web based access to important newsgroups related to databasesCan 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
Post Follow-up to this messageJohn 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
Post Follow-up to this messageTry 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
Post Follow-up to this messageThat 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... > > >
Post Follow-up to this messageActually - 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... > > >
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread