Self-built process for viewing table structure
CREATE PROC [Sp_tablehelp](@TableName VARCHAR( -)= "',@ColName VARCHAR( -)="') asBEGIN --table structure Quick Check --Brin --DECLARE @TableName VARCHAR (+) --DECLARE @ColName VARCHAR (+) --SET @TableName = ' Tlocatormove ' --SET @ColName = ' Nstatus ' SELECTTableName=( Case whenCol.colorder= 1 OR @TableName is NULL ThenObj.nameELSE "' END), Colorder=Col.colorder, ColName=Col.name, Coldescription= ISNULL(Ep.value,"'), Coltype=T.name, Collength=Col.length, Colscale= ISNULL(ColumnProperty(Col.id, Col.name,' Scale'),0), Colisidentity=( Case when ColumnProperty(Col.id, Col.name,'isidentity')= 1 Then '√' ELSE "' END), COLISPK=( Case when EXISTS(SELECT 1 fromsys.sysindexes siJOINSys.sysindexkeys Sik onSi.id=Sik.id andSi.indid=Sik.indidJOINSys.syscolumns SC onSc.id=Sik.id andSc.colid=Sik.colidJOINSys.sysobjects so onSo.name=Si.name andSo.xtype= 'PK' WHERESc.id=Col.id andSc.colid=Col.colid) Then '√' ELSE "' END), Colisnull=( Case whenCol.isnullable= 1 Then '√' ELSE "' END), Coldefaultvalue= ISNULL(Comm.text,"') fromSys.syscolumns Col Left JOINSys.systypes T onCol.xtype=T.xusertypeINNER JOINSys.sysobjects obj onCol.id=Obj.id andObj.xtype= 'U' andObj.status>= 0 and(Obj.name= @TableName OR ISNULL(@TableName,"')="' ) Left JOINSys.syscomments Comm onCol.cdefault=comm.id Left JOINSys.extended_properties EP onCol.id=ep.major_id andCol.colid=ep.minor_id andEp.name= 'ms_description' Left JOINSys.extended_properties Eptwo onObj.id=eptwo.major_id andeptwo.minor_id= 0 andEptwo.name= 'ms_description' WHERE 1=1 and(Col.name= @ColName OR ISNULL(@ColName,"')="') ORDER byObj.name,col.colorder; END
SQL Server self-built process for viewing table structure