Home Microsoft SQL Server DigiMailing iRN Contact
    Keyword



sys.sp_IHscriptpkwhereclause

  No additional text.


Syntax


-- Name:
--          sp_IHscriptpkwhereclause

-- Description:
--          Script primary key where clause

-- Security:
--          Public (for use by snapshot agent)

-- Returns:
--          Success or failure
--			Temp table (#proctext) of commands

-- Owner:
--          


create procedure sys.sp_IHscriptpkwhereclause
(
	@src_objid		int,
	@artid			int,
	@prefix			nvarchar(10) = N'@pkc',
	@artcolcounter	bit = 0						-- 0 means it does column counting base on pk, 1 means base on article columns
)
as
begin
	declare @this_col int
	declare @art_col int
	declare @spacer nvarchar(10)
	declare @isset int
	declare @cmd nvarchar(4000)
	declare @col_name nvarchar(128)

	-- create WHERE clause

	select @art_col = 0
	select @spacer = N' '
	select @cmd = N'where'

	DECLARE hCColid CURSOR LOCAL FAST_FORWARD FOR
	select	ihc.publishercolumn_id, ihsc.name
	from	IHcolumns ihc,
			IHsyscolumns ihsc
	where	ihc.column_id = ihsc.colid
	  and	ihscid = @src_objid
	order by ihsc.colorder asc

	OPEN hCColid

	FETCH hCColid INTO @this_col, @col_name

	WHILE (@@fetch_status <> -1)
	begin
		--skipping columns with no name (computed?)
		if EXISTS (select name from IHsyscolumns where id=@src_objid and @this_col=colid)
		begin
			-- If @artcolcounter = 1, it is called from
			-- sp_scriptxupdproc or sp_scriptxdelproc
			-- Use counter in article column bitmap
			-- Otherwise use counter in pk bitmap
			if @artcolcounter = 1
			begin
				exec @isset = sys.sp_IHisarticlecolbitset @this_col, @artid
				if @isset != 0
					select @art_col = @art_col + 1
			end
			exec @isset = sys.fn_IHiscolpk @this_col
			if @isset != 0
			begin
				if @artcolcounter = 0
					select @art_col = @art_col + 1
				select @cmd = @cmd + @spacer + QUOTENAME(@col_name) + N' = ' + @prefix + convert( nvarchar, @art_col )
				select @spacer = N' and '
				if len( @cmd ) > 3000
				begin
					insert into #proctext(procedure_text) values( @cmd )
					select @cmd = N''
				end
			end
		end
		FETCH hCColid INTO @this_col, @col_name
	end
	CLOSE hCColid
	DEALLOCATE hCColid

	insert into #proctext(procedure_text) values( @cmd )
end

 
Last revision 2008RTM
See also

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