T-SQL Tutorial

T-SQL Sp_special_columns


On Transact SQL language the sp_special_columns is part of Catalog Stored Procedures and return the optimal set of columns that uniquely identify a row in the table.

Sp_special_columns syntax:


sp_special_columns [ @table_name = 'Table name.' ] ,
[ @table_owner = 'The database user who created the table.' ] ,
[ @table_qualifier = 'Database name.' ] ,
[ @col_type = 'Column type.' ] ,
[ @scope = 'The minimum required scope of the ROWID.' ] ,
[ @nullable = 'The special columns can accept a null value.' ] ,
[ @ODBCVer = 'ODBC Version 2 or 3.' ] ;





Sp_special_columns example 1:

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

Sp_special_columns example 2:

USE model;
GO
EXEC sp_special_columns
@table_name = 'students',
@table_owner = 'dbo',
@table_qualifier = 'model',
@col_type = 'V',
@nullable = 'O',
@ODBCVer = '3';