
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[p_sys_md_csharp_print_idtexttable] 
	@tbl as IdTextTableType READONLY,
	@add_comma_after bit
AS
BEGIN
	SET NOCOUNT ON;
	
	declare @id int
	declare @min_id int
	declare @max_id int
	declare @txt varchar(max)
	
	select @min_id = min(id), @max_id = max(id)
	from @tbl
	
	set @id = @min_id
	
	while @id <= @max_id
	begin
		select @txt = txt from @tbl where id = @id
		
		if @id < @max_id and @add_comma_after = 1
			set @txt = @txt + ','
			
		print @txt
		
		set @id = @id + 1
	end

END

GO
