404
Part IV: Programming with T-SQL
Result:
Table Primary Key
-------------------------- --------------------------------------
dbo.ErrorLog PK_ErrorLog_ErrorLogID
Person.Address PK_Address_AddressID
Person.AddressType PK_AddressType_AddressTypeID
dbo.AWBuildVersion PK_AWBuildVersion_SystemInformationID
Production.BillOfMaterials PK_BillOfMaterials_BillOfMaterialsID
Production.Document UQ__Document__F73921F793071A63
Person.BusinessEntity PK_BusinessEntity_BusinessEntityID
sp_help
Sp_help, and its variations, return information regarding the server, database, objects,
connections, and more. The basic sp_help lists the available objects in the current
database; the other variations provide detailed information about the various objects or
settings.
Adding an object name as a parameter to sp_help returns additional appropriate informa-
tion about the object:
USE AdventureWorks2012;
GO
sp_help 'Production.Product';
The result here is nine data sets of information about the Production.Product table:
■ Name, creation date, and owner
■ (^) Columns
■ Identity columns
■ (^) Row GUID columns
■ FileGroup location
■ (^) Indexes
■ Constraints
■ (^) Foreign Key references
■ View references
System Functions
A system function, sometimes called a global variable, returns information about the cur-
rent system or connection status.
c16.indd 404c16.indd 404 7/30/2012 5:38:08 PM7/30/2012 5:38:08 PM
http://www.it-ebooks.info