Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

sql server

exec sp_spaceused [[@objname=]'objname'][,[@updateusage=]'updateusage']
¼ì²éÊý¾Ý¿â¿Õ¼ä´óС
 dbcc   showfilestats
ͳ¼ÆÊý¾ÝÎļþµÄʹÓÃÇé¿ö
 dbcc   showcontig
¼ì²éÊý¾Ý¿â¿Ø¼þ·ÖÅäÇé¿ö
 dbcc   sqlperf(logspace)
²é¿´ÈÕÖ¾ÎļþµÄʹÓÃÇé¿ö ......

PHPÁ¬½ÓSQL Server

ʹÓùýSQL ServerµÄÈËÓ¦¸Ã¶¼Çå³þ£¬SQL Server³£ÓõÄÓÐÁ½ÖÖÈÏÖ¤·½Ê½£¬Ò»ÖÖÊDZ¾µØÏµÍ³ÕË»§ÈÏÖ¤£¨Windows Authentication £©£¬Ò»ÖÖÊÇʹÓÃÓû§ÃûºÍÃÜÂ루SQL Server Authentication £©£¬µÚ¶þÖÖÈÏÖ¤·½Ê½±ØÐëÆôÓÃSQL ServerµÄ»ìºÏģʽ¡£
¡¡¡¡1.Windows AuthenticationÁ¬½Ó²¿·Ö´úÂë¶Î£º
<?php
$serverName = "(local)";
$co ......

SQLÖлñµÃEXECºóÃæµÄsqlÓï¾ä»ò·µ»ØÖµµÄ·½·¨

SQLÖлñµÃEXECºóÃæµÄsqlÓï¾ä»ò·µ»ØÖµµÄ·½·¨
ǰÑÔ£ºÔÚÊý¾Ý¿â³ÌÐò¿ª·¢µÄ¹ý³ÌÖÐ,ÎÒ勱ÃǾ­³£»áÅöµ½Ñ§Ï°ÀûÓÃEXECÀ´Ö´ÐÐÒ»¶ÎÐèÒª·µ»ØÄ³Ð©ÖµµÄsqlÓï¾ä£¨Í¨³£Êǹ¹Ô춯̬sqlÓï¾äʱʹÓã©£¬»òÕßÔÚÒ»¸öHTML´æ´¢¹ý³ÌÖÐÀûÓÃEXECµ÷ÓÃÁíÒ»¸öHTMLÓзµ»ØÖµµÄ´æ´¢¹ý³Ì£¨±ØÐë»ñµÃ·µ»ØÖµ£©£¬ÄÇôÈçºÎ»ñµÃÕâЩ·µ»ØÖµÄØ?
1.EXECÖ´ÐÐsqlÓï¾ ......

ͬ²½Á½¸öSql server

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

ÌáÉýOracleÐÔÄÜÖ®SQLµÄÓÅ»¯Ïêϸ·ÖÎö

SQLµÄÓÅ»¯Ó¦¸Ã´Ó5¸ö·½Ãæ½øÐе÷Õû£º
1.È¥µô²»±ØÒªµÄ´óÐͱíµÄÈ«±íɨÃè
2.»º´æÐ¡ÐͱíµÄÈ«±íɨÃè
3.¼ìÑéÓÅ»¯Ë÷ÒýµÄʹÓÃ
4.¼ìÑéÓÅ»¯µÄÁ¬½Ó¼¼Êõ
5.¾¡¿ÉÄܼõÉÙÖ´Ðмƻ®µÄCost
SQLÓï¾ä£º
ÊǶÔÊý¾Ý¿â(Êý¾Ý)½øÐвÙ×÷µÄΩһ;¾¶£»
ÏûºÄÁË70%~90%µÄÊý¾Ý¿â×ÊÔ´£»¶ÀÁ¢ÓÚ³ÌÐòÉè¼ÆÂß¼­£¬Ïà¶ÔÓÚ¶Ô³ÌÐòÔ´´úÂëµÄÓÅ»¯£¬¶ÔSQLÓï¾äµÄÓÅ»¯Ô ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ