Hi,
How do we find the "column name" and "data type" of all the columns in a table. Assuming that I know the Table name or Table Object ID. I am using Microsoft SQL Server 2000.
Thanks
-SudhakarHi sudhakar_112
Have a peak at the INFORMATION_SCHEMA tables in BoL - terribly useful.
Specifically:
SELECT COLUMN_NAME,
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'MyTable'
HTH|||Thank you..
using the following query lists only the columns that are acessible to the user. If the user does not have permission on a column it will not be displayed. But I want a query to display all column names irrespective of the user has any permissions to modify or select.
Thanks
-Sudhakar
Hi sudhakar_112
Have a peak at the INFORMATION_SCHEMA tables in BoL - terribly useful.
Specifically:
SELECT COLUMN_NAME,
DATA_TYPE,
CHARACTER_MAXIMUM_LENGTH
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'MyTable'
HTH|||You can construct a query on the syscolumns and sysobjects tables - these are not dependent on the user permissions.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment