May 14, 2012

sp_MSfilterclause (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


sys.sp_MSfilterclause(nvarchar @publication
, nvarchar @article)


create procedure sys.sp_MSfilterclause
@publication nvarchar(258), @article nvarchar(258)
-- Return a text column as multiple readtexts of maxcol length --
declare @pubid int, @artid int
select @pubid = pubid from syspublications where name = @publication
if (@pubid is null) begin
RAISERROR (15001, 11, -1, @publication)
return 1
select @artid = artid from sysarticles where name = @article and pubid = @pubid
if (@artid is null) begin
RAISERROR (15001, 11, -1, @article)
return 1

declare @val varbinary(16), @len int, @ii int, @chunk int
-- filter clause is in unicode, the length is a half of the number of bytes.
select @val = textptr(filter_clause), @len = datalength(filter_clause)/2 from sysarticles where artid = @artid and pubid = @pubid
select @ii = 0, @chunk = 255

-- Get all the rows of an maxcol size --
while @len > @chunk begin
readtext sysarticles.filter_clause @val @ii @chunk
select @ii = @ii + @chunk, @len = @len - @chunk

-- Get the last chunk --
if (@len > 0)
readtext sysarticles.filter_clause @val @ii @len
return 0

No comments:

Post a Comment

Total Pageviews