Saturday, February 25, 2012

[howto] write a function that process row collection

something like max,min?
help please!!!SQL Server doesn't extend that level of functionality to end users yet.

-PatP|||thank you.
another question:
is it avaliable in the most recent sql server version(v2005)?|||I can't answer that question. Sorry.

-PatP|||thanks
i found something here
http://msdn.microsoft.com/data/sqlsolutions/sql2005/default.aspx?pull=/library/en-us/dnsql90/html/sql_ovyukonnetprogfeatures.asp|||looks great
==========================================
using System.Data.SqlServer;
using System.Data.Sql;
public class T {
[SqlFunc]
[SqlFunction(DataAccess = DataAccessKind.Read)]
public static int ReturnOrderCount()
{
SqlCommand sqlComm = SqlContext.GetCommand();

sqlComm.CommandText = "SELECT COUNT(*) AS 'Order Count' FROM SalesOrderHeader";

return (int) sqlComm.ExecuteScalar();
}
}

------------------------
Using System.Data.Sql;
Using System.Data.SqlServer;
Class T {
[SqlProcedure]
public static void HelloWorld()
{
SqlPipe sp = SqlContext.GetPipe();

sp.Send("Hello world! It's now " + System.DateTime.Now.ToString()+"\n");
SqlCommand cmd = SqlContext.GetCommand()
cmd.CommandText = ??SELECT ProductNumber FROM ProductMaster??
SqlDataReader rdr = cmd.ExecuteReader();
Sp.Send(rdr);
}
}

No comments:

Post a Comment