C# SQL Server中的按位OR函数
我想创建一个自定义按位或聚合函数。 我想像使用内置聚合函数一样使用它(MIN、MAX等) 其中,位_字符串是nvarchar(3) 例如,如果表包含两行('100','001'),那么上面的查询应该返回'101' 我希望将其实现为具有以下聚合的CLR函数/程序集:C# SQL Server中的按位OR函数,c#,sql-server,aggregate-functions,sqlclr,bitwise-or,C#,Sql Server,Aggregate Functions,Sqlclr,Bitwise Or,我想创建一个自定义按位或聚合函数。 我想像使用内置聚合函数一样使用它(MIN、MAX等) 其中,位_字符串是nvarchar(3) 例如,如果表包含两行('100','001'),那么上面的查询应该返回'101' 我希望将其实现为具有以下聚合的CLR函数/程序集: CREATE AGGREGATE dbo.bitwise_or (bit_string nvarchar(3)) RETURNS [nvarchar(3)] EXTERNAL NAME [Aggregate].[bitwise_or]
CREATE AGGREGATE dbo.bitwise_or (bit_string nvarchar(3))
RETURNS [nvarchar(3)]
EXTERNAL NAME [Aggregate].[bitwise_or]
有人能给我一个c代码的快速启动吗
我跟随这篇文章实现了amedian聚合函数:
但是有很多代码(不确定我的情况下真正需要什么)这个链接很好地解释了这一切:
[Serializable]
[SqlUserDefinedAggregate(Format.Native)]
public struct Bitwise_or
{
//Implement the function below
// Initialize any reource here, called once
public void Init()
{
}
// Decides what action to take for each row value
public void Accumulate()
{
}
// Used by SQL Server when large amount of data is processed
public void Merge()
{
}
// Free up resources
public void Terminate()
{
}
}
[Serializable]
[SqlUserDefinedAggregate(Format.Native)]
public struct Bitwise_or
{
//Implement the function below
// Initialize any reource here, called once
public void Init()
{
}
// Decides what action to take for each row value
public void Accumulate()
{
}
// Used by SQL Server when large amount of data is processed
public void Merge()
{
}
// Free up resources
public void Terminate()
{
}
}