2005ºó£¬MSSQLÔö¼ÓÁËÐÂÌØÐÔ¡£
½ñÌìÉÔ´øÁ˼¸ÑÛ£¬ÈçÊý¾Ý¿â´¥·¢Æ÷£¬¼Ü¹¹£¬Êý¾Ý¿â´¥·¢Æ÷£¬·þÎñÆ÷´¥·¢Æ÷µÈ¡£ºÜ¶àÊÇеÄÄÚÈÝ£¬ÓÐЩÊǸÅÄî·¢ÉúÁËһЩ±ä»¯¡£
ÓÐЩSQLµÃµ½ÁËÔöÇ¿¡£
Èçfromºó¿ÉÒÔ¸ú²ÉÑùÓï¾ä£¬½»²æ±í£¬xmlµÈ£¬PIVOTºÍUNPIVOTµÈÔËËãÊDz»ÊÇ¿ÉÒÔʹÆäÖеÄһЩÎÊÌâºÜ¼òµ¥µØ¾Í´¦ÀíÁË¡£
´ó¼Ò¿ÉÒÔɹһɹ×Ô¼ºÖªµ ......
»áÔ±ID£ºws_hgo
ÉêÇë°æÃ棺SQL ServerÒÉÄÑÎÊÌâ
ÉêÇë°æÖ÷ÀíÓÉ£ºÏ£ÍûÔÚCSDN¾¡¿ÉÄܵİïÖú´ó¼Ò,Ï£ÍûÄܹ»ºÍ´ó¼ÒÒ»ÆðÌá¸ßMSSQL¼¼Êõ
ƽ¾ùÉÏÍøʱ¼ä(Сʱ/Ìì)£º>12Сʱ
ÊÇ·ñµ£Èιý±¾ÉçÇø»òÕßÆäËûÉçÇøÏà¹ØÖ°Îñ£ºÎÞ
¶ÔÉêÇë°æÃæÏÖ×´¼°ÄúµÄ¹ÜÀí¸Ä½øÒâ¼û:
(1)ÕûÀí×Ô¼ºÈÕ³£Ñ§Ï°,¹¤×÷µÄ°¸ÀýºÍ´ó¼Ò·ÖÏí
(2)¶¨ ......
SQL code:
For Ls_desc IN (Select Di_ename ,Di_Pcs,Di_Unitprice
from T_BO_DeclareInvoice Di
WHERE bs_code = as_bs_code)
LOOP
IF Ls_desc.Di_ename IS NOT NULL THEN
--Quantity 1
ls_dhl_string := ls_dhl_string ||To_Ch ......
asp+mssql ¸ÃÈçºÎ·µ»ØÈçÏÂÐÅÏ¢ÄØ
±ÈÈçÒ»¸ö±íÀïÃæµÄÊý¾Ý
date info
2009-1-1 13:00:00 12345
2009-1-1 13:00:01 12345
2009-1-1 13:00:02 12345
2009-1-2 13:00:03 12345
2009-1-2 13:00:04 12345
2009-1-2 13:00:05 12345
2009-1-3 13:00:06 1 ......
±ÈÈç
Ò»¸öÊÇÓû§Áбí
UserID
1
2
3
4
Ò»¸öÊÇ´ÎÊýÁбí(ÿÌì·ÃÎÊÒ»´ÎNum+1)
UserID Day Num
1 2009-09-22 10
2 2009-09-22 20
4 2009-09-22 8
ÏëÒªµÄ½á¹ûÊÇ
2 20
1 10
4 8
3 0
ÐèÒª°´·ÃÎÊ´Î ......
±ÈÈç
Ò»¸öÊÇÓû§Áбí
UserID
1
2
3
4
Ò»¸öÊǼǼÁбí(ÿ¸öÓû§Ò»Ìì¿ÉÄÜÓжàÌõÊý¾Ý)
UserID Day
1 2009-09-22
1 2009-09-22
1 2009-09-22
2 2009-09-22
2 2009-09-22
2 2009-09-22
2 2009-09-22
4 2009-09-22
4 2009-09-22
ÏëÒªµÄ½á¹ûÊÇ
......