using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;


public partial class StoredProcedures
{
	[Microsoft.SqlServer.Server.SqlProcedure]
	public static void Pipeline()
	{
		SqlMetaData[] m = new SqlMetaData[1] {new SqlMetaData("colname", SqlDbType.NVarChar, 5) };
		SqlDataRecord rec = new SqlDataRecord(m);

		rec.SetSqlString(0, "Hello");
		SqlPipe p = SqlContext.Pipe;
		p.SendResultsStart(rec);
       
		for (int i=0;i<10000;i++)
			p.SendResultsRow(rec);
		Int64 j = 0;
		for (Int64 i = 0; i < 10000000000; i++) { j++; }
		System.Threading.Thread.Sleep(10000);
    p.SendResultsEnd();

    /*
    SqlMetaData[] m1 = new SqlMetaData[1] { new SqlMetaData("colname1", SqlDbType.Int) };
    SqlDataRecord rec1 = new SqlDataRecord(m1);
    p.SendResultsStart(rec1);

    rec1.SetSqlInt32(0, 42);
		for (int i = 0; i < 10000; i++)
			p.SendResultsRow(rec1);
		System.Threading.Thread.Sleep(10000);
		for (int i = 0; i < 10000; i++)
			p.SendResultsRow(rec1);
		System.Threading.Thread.Sleep(10000);
		p.SendResultsEnd();
		System.Threading.Thread.Sleep(10000);
     */    
	}
};
