June 4, 2012

sp_MStablechecks (Transact-SQL MetaData) Definition

Please note: that the following source code is provided and copyrighted by Microsoft and is for educational purpose only.
The meta data is from an SQL 2012 Server.

I have posted alot more, find the whole list here.

Goto Definition or MetaData

Definition:

sys.sp_MStablechecks(nvarchar @tablename
, int @flags)

MetaData:

   
create procedure sys.sp_MStablechecks
@tablename nvarchar(517), @flags int = null
as
-- -- @flags added for DaVinci uses. If the bit isn't set, use 6.5 -- --
-- -- sp_MStablechecks '%s' -- --

declare @id int
select @id = object_id(@tablename)
if (@id is null) begin
RAISERROR (15001, -1, -1, @tablename)
return 1
end

-- @flags is for daVinci. --
if (@flags is null)
select @flags = 0

-- We'll put out the check text if it's all in one row (most likely); otherwise leave it --
-- blank for refetching in its entirety via sp_helptext, unless @flags wants it anyway. --
select object_name(t.id),
case when (@flags & 1 <> 0 or not exists (select * from dbo.syscomments where id = t.id and colid = 2))
then t.text else null end,
c.status & (convert(int, 0x00200000) | convert(int, 0x00020000) | convert(int, 0x00004000)),
OBJECTPROPERTY( t.id, N'CnstIsDisabled' )
from dbo.syscomments t, dbo.sysconstraints c
where t.id = c.constid and c.id = @id and c.status & 0x0f = 4
and (@flags & 1 <> 0 or t.colid = 1)
order by object_name(t.id), t.colid

No comments:

Post a Comment

Total Pageviews