Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_MSmerge_parsegenlist

  No additional text.


Syntax
create procedure sys.sp_MSmerge_parsegenlist
    @genlist varchar(8000),
    @gendeclarelist varchar(max) OUTPUT,
    @genselectlist varchar(max) OUTPUT,
    @genunionlist varchar(max) OUTPUT
as 			
    declare @gencount int	
    declare @counter int
    declare @listsize int
    declare @position1 int
    declare @position2 int
		
    select @gendeclarelist = ' '
    select @genselectlist = ' '
    select @genunionlist = ' '

    exec sys.sp_MSmerge_getgencount @genlist, @gencount output
	
    if @gencount = 0
        return

	-- for better performance of enum queries, limit the number of queries by
	-- using a small set of gen buckets
    if @gencount <= 10
        set @listsize = 10
    else if @gencount <= 25
        set @listsize = 25
    else if @gencount <= 50
        set @listsize = 50
    else if @gencount <= 100
        set @listsize = 100
    else if @gencount <= 200
        set @listsize = 200
    else if @gencount <= 500
        set @listsize = 500
    else if @gencount <= 1000
        set @listsize = 1000
    else if @gencount <= 1500
        set @listsize = 1500
    else if @gencount <= 2000
        set @listsize = 2000
    else
        set @listsize = @gencount

    if @listsize <> 0 and @gencount > @listsize
        return

    -- if we get this far, we have at least one gen
    set @counter = 1
    set @position1 = 1
    set @position2 = charindex(',', @genlist, @position1)

    declare @tempint bigint	        		

    while @counter < @listsize
    begin		        		
        select @gendeclarelist = @gendeclarelist + '
    declare @gen' + convert(varchar(16), @counter) + ' bigint '
		
        if @counter < @gencount
        begin
            select @tempint = CONVERT(bigint, substring(@genlist, @position1, @position2 - @position1))
            select @genselectlist = @genselectlist + '
    select @gen' + convert(varchar(16), @counter) + ' =  ' + CONVERT(varchar(20), @tempint)
        end
        else if @counter = @gencount
        begin
            select @tempint = CONVERT(bigint, substring(@genlist, @position1, len(@genlist) - (@position1-1)))
            select @genselectlist = @genselectlist + '
    select @gen' + convert(varchar(16), @counter) + ' =  ' + CONVERT(varchar(20), @tempint)
        end
        else
            select @genselectlist = @genselectlist + '
    select @gen' + convert(varchar(16), @counter) + ' =  null '

        select @genunionlist = @genunionlist + '
            select @gen' + + convert(varchar(16),@counter) + ' as gen union all '
	
        set @counter = @counter + 1
        set @position1 = @position2 + 1
        set @position2 = charindex(',', @genlist, @position1)               				
    end		
	
    -- parse last gen in the list
        select @gendeclarelist = @gendeclarelist + '
    declare @gen' + convert(varchar(16), @counter) + ' bigint '
	
    if @counter = @gencount
    begin
        select @tempint = CONVERT(bigint, substring(@genlist, @position1, len(@genlist) - (@position1-1)))
        select @genselectlist = @genselectlist + '
    select @gen' + convert(varchar(16), @counter) + ' =  ' + CONVERT(varchar(20), @tempint)
    end
    else
        select @genselectlist = @genselectlist + '
    select @gen' + convert(varchar(16), @counter) + ' =  null '

        select @genunionlist = @genunionlist + '
        select @gen' + + convert(varchar(16), @counter) + ' as gen '
	
    return 0

 
Last revision 2008RTM
See also

  sp_MSdrop_rlcore (Procedure)
sp_MSenumchangesdirect (Procedure)
sp_MSenumchanges_belongtopartition (Procedure)
sp_MSenumchanges_notbelongtopartition (Procedure)
sp_MSenumdeletes_forpartition (Procedure)
       



News

  Query a named instance
Sybase+ASE+silent+install
SQL 2008 R2
Deprecated procedures in SQL2008
Reporting Services item-level role definitions
Create all your missing indexes
Converting datetime field
Start MSSQL Server Profiler at time
Replicating MSSQL Server views
Exploring Microsoft Sharepoint
The OLE DB provider "SQLNCLI10" for linked server indicates.
Mobile solar charger
Oracle to SQL Server replication
Cannot insert the value NULL into column
Undocumented Microsoft SQL Server 2008
VMware
Zoekmachine optimalisatie
SQL Servers hidden objects
FckEditor
Flash in Ajax
De hype die AJAX heet
Barcode scannen
MySQL; Gratis, makkelijk en snel!
PHP
sIFR; de combinatie tussen HTML en Flash