Hi!
How can I use a transact SQL to get a list of columns for a specific
table withing a specific database?
Thank you,
T.
There is a variety of ways. You can use:
EXEC sp_columns 'tblname'
or query the information schema view:
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 't' ;
or even
EXEC sp_help tablename ;
Anith
|||One more way (SQL Server 2005):
SELECT O.name AS table_name,
C.name AS column_name,
SCHEMA_NAME(O.schema_id) AS 'schema_name'
FROM sys.objects AS O
JOIN sys.columns AS C
ON O.object_id = C.object_id
WHERE O.type IN ('U')
AND O.name = 'YourTableName';
HTH,
Plamen Ratchev
http://www.SQLStudio.com
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment