T-SQL Tutorial

T-SQL Sp_columns


On Transact SQL language the sp_columns is part of Catalog Stored Procedures and return column information for the specified objects that can be queried in the database.

Sp_columns syntax:

sp_columns [ @table_name = 'Object name.' ] ,
[ @table_owner = 'The database user who created the table.' ] ,
[ @table_qualifier = 'Database name.' ] ,
[ @column_name = 'Column name.' ] ,
[ @ODBCVer = 'ODBC Version 2 or 3.' ] ;





Sp_columns example 1:

USE model;
GO
EXEC sp_columns
@table_name = 'students',
@table_owner = 'dbo';

Sp_columns example 2:

USE model;
GO
EXEC sp_columns
@table_name = 'students',
@table_owner = 'dbo',
@table_qualifier = 'model',
@column_name = 'first_name';