Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

×Ô¶¨Òå¶à²ÎÊýSql¾ÛºÏº¯Êý

Creating a CLR user define aggregate (part 2). Use multiple columns in the aggregation function
In part 1 we created a nice user defined aggregate. Now we are going to make it more sophisticated and let its value depend on two parameters ShipCountry and ShipShipCity. You might try having two parameters in Accumulate function of the aggregate but you will get an error
The Accumulate method in user defined aggregate "Bonus" must have exactly one parameter.
We are definitely looking into adding “multi-column aggregates” feature in the future versions of SQL Server. For now you can use a workaround. The idea is to create a worker UDT that contain all the fields required for the aggregation. So if you want to take Orders.ShipCountry and Orders.ShipCity into account the UDT should have two corresponding fields. You also need to create a user defined function that takes a number of parameters and returns an instance of the worker UDT. And finally you create an aggregate that takes the worker UDT as a parameter in its aggregation function.
Let’s say XYZ wants to consider German sales that has been shipped to Berlin as regular sales. To take ShipCity this into account you first need to create a UDT. I won’t implement several methods to keep the sample short.
[Serializable]
[Microsoft.SqlServer.Server.SqlUserDefinedType(Format.UserDefined, MaxByteSize=8000)]
public struct OrderData : INullable, IBinarySerialize
{
    public override string ToString()
    {
        throw new Exception("The method or operation is not implemented.");
    }
 
    public bool IsNull
    {
        get
        {
            return false;
        }
    }
 
 &n


Ïà¹ØÎĵµ£º

SQLite²»Ö§³ÖµÄSQLÓï·¨×ܽá


1 TOP
ÕâÊÇÒ»¸ö´ó¼Ò¾­³£Îʵ½µÄÎÊÌ⣬ÀýÈçÔÚSQLSERVERÖпÉÒÔʹÓÃÈçÏÂÓï¾äÀ´È¡µÃ¼Ç¼¼¯ÖеÄǰʮÌõ¼Ç¼£º
SELECT TOP 10 * from [index] ORDER BY indexid DESC;
µ«ÊÇÕâÌõSQLÓï¾äÔÚSQLiteÖÐÊÇÎÞ·¨Ö´Ðеģ¬Ó¦¸Ã¸ÄΪ£º
SELECT * from [index] ORDER BY indexid DESC limit 0,10;
ÆäÖÐlimit 0,10±íʾ´ÓµÚ0Ìõ¼Ç¼¿ªÊ¼£¬Íùºó ......

vfp/(asp/vfpdll/Sql)

ÒÔÏÂÊÇ·¢ÔÚ÷×ÓÂÛ̳µÄÌù×Ó£¬×ª·¢¹ýÀ´£¬Ï£Íû¸øÓõÃ×ŵĺüÓѲο¼¡£
ÎҵijÌÐòÒÔǰһֱÊÇÓû¨Éú¿Ç°ó¶¨IPʵÏÖµÄÔ¶³Ì£¬ÓÉÓÚ¿Í»§·þÎñÆ÷ºÍ¿Í»§¶Ë¶¼ÊÇͨ¹ý¿í´øÉÏÍø£¬Ò»°ãµÄ²Ù×÷£¨¿ª½ø»õµ¥¡¢ÏúÊÛµ¥µÈ£©ËÙ¶ÈÒ²»¹²»´í£¬µ«ÊÇÔÚÔ¶³Ì¿Í»§¶ËÐÞ¸ÄÉÌÆ·×ÊÁÏ£¨10000¶àÌõ¼Ç¼£©¡¢²éѯһ¶ÎʱÆÚµÄ½øÏú´æÁ÷Ë®£¨Ò»ÖÜ5000ÌõÒÔÉÏ£©µÈÉæ¼°µ½È¡¼Ç¼Á¿´óµ ......

ͬ²½Á½¸öSql server

--1:»·¾³
¡¡¡¡·þÎñÆ÷»·¾³:
¡¡¡¡»úÆ÷Ãû³Æ£º ZehuaDb
¡¡¡¡²Ù×÷ϵͳ£ºWindows 2000 Server
¡¡¡¡Êý¾Ý¿â°æ±¾£ºSQL 2000 Server ¸öÈ˰æ
¡¡¡¡¿Í»§¶Ë
¡¡¡¡»úÆ÷Ãû³Æ£ºZlp
¡¡¡¡²Ù×÷ϵͳ£ºWindows 2000 Server
¡¡¡¡Êý¾Ý¿â°æ±¾£ºSQL 2000 Server ¸öÈ˰æ
¡¡¡¡--2:½¨Óû§ÕʺÅ
¡¡¡¡ÔÚ·þÎñÆ÷¶Ë½¨Á¢ÓòÓû§ÕʺÅ
¡¡¡¡ÎҵĵçÄÔ¹ÜÀí- ......

sql server Óë oracleÓï·¨¶Ô±È.

ORACLEÓëSQL SERVERÓï·¨Çø±ð
 
Ò»¡¢Êý¾ÝÀàÐÍ
ORACLEÓëSQL SERVERÔÚÊý¾ÝÀàÐ͵ĶԱÈÈçÏ£º
 
SQL SERVER
ORACLE
Êý×ÖÀàÐÍ
DECIMAL[(P[, S])]
NUMBER[(P[, S])]
NUMERIC[(P[, S])]
NUMBER[(P[, S])]
FLOAT[(N)]
NUMBER[(N)]
INT
NUMBER
SMALLINT
NUMBER
TINYINT
NUMBER
MONEY
NUMBER[19,4]
SM ......

sql ·Ö¸î×Ö·û´® Êä³ö

ʾÀý£º
´«Èë¶à¸öEmailµØÖ·,ͨ¹ýÿ¸öEmailµØÖ·¼äµÄ','·Ö¸ô·û£¬½«¸÷EmailµØÖ··Ö¿ª¡£
SELECT * from dbo.uf_Split('aa@aa.com,bb@bb.com,cc@cc.com,dd@dd.com',',');
²éѯ½á¹û£º
subid      autoid
aa@aa.com 1
bb@bb.com 2
cc@cc.com 3
dd@dd.com 4
ÏÂÃæÊÇ[uf_Split]·½·¨µÄ¾ßÌåʵÏÖ£º
CREATE   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ