SQL°´ÕÕÈÕ¡¢ÖÜ¡¢Ô¡¢Äêͳ¼ÆÊý¾Ý
Èç: ±í:consume_record
×Ö¶Î:consume (moneyÀàÐÍ) date (datetimeÀàÐÍ)
ÇëÎÊÔõôдËÄÌõsqlÓï¾ä·Ö±ð°´ÈÕ,°´ÖÜ,°´ÔÂ,°´¼¾Í³¼ÆÏû·Ñ×ÜÁ¿.
Èç:1ÔÂ 1200Ôª
2ÔÂ 3400Ôª
3ÔÂ 2800Ôª
--°´ÈÕ
select sum(consume),day([date]) from consume_record where year([date]) = '2006' group by day([date])
--°´ÖÜquarter
select sum(consume),datename(week,[date]) from consume_record where year([date]) = '2006' group by datename(week,[date])
--°´ÔÂ
select sum(consume),month([date]) from consume_record where year([date]) = '2006' group by month([date])
--°´¼¾
select sum(consume),datename(quarter,[date]) from consume_record where year([date]) = '2006' group by datename(quarter,[date])
--Ö¸¶¨ÈÕÆÚÄã¾Í¿´ÉÏÃæµÄÀý×Ó±äͨÏÂѽ£¬Î޷ǾÍÊÇÒ»¸ö¾ÛºÏº¯ÊýºÍGroup by
select [date],sum(consume) from consume_record where [date] between '2006-06-01' and '2006-07-10' group by [date]
Ïà¹ØÎĵµ£º
SQL Server 2005 ºÍ2008ÌṩÁ˺ܶàеĺÍÔöÇ¿µÄÉÌÎñÖÇÄܹ¦ÄÜ,°üÀ¨ÀûÓü¯³É·þÎñ(SSIS)ÕûºÏ¶àÖÖÊý¾ÝÔ´;ÀûÓ÷ÖÎö·þÎñ(SSAS)ʹÊý¾ÝÄÚÈݸü·á¸»²¢ÇÒ½¨Á¢¸´ÔÓµÄÉÌÒµ·ÖÎö; ÒÔ¼°ÀûÓñ¨±í·þÎñ(SSRS)±à¼,¹ÜÀí,ºÍÌá½»·á¸»µÄ±¨±í. Èç¹ûÄãÏÖÔÚ»¹²»Çå³þÕâЩ¹¦ÄÜ,ÄÇô½ÓÏÂÀ´Ò»ÏµÁеĽéÉÜ»áÈÃÄã¶ÔSQL ServerÏÖÔÚµÄÉÌÎñÖÇÄÜÖ§³Ö´ó³ÔÒ»¾ª.²»¹ý ......
1. ËÀËøÔÀí
¸ù¾Ý²Ù×÷ϵͳÖеĶ¨Ò壺ËÀËøÊÇÖ¸ÔÚÒ»×é½ø³ÌÖеĸ÷¸ö½ø³Ì¾ùÕ¼Óв»»áÊͷŵÄ×ÊÔ´£¬µ«Òò»¥ÏàÉêÇë±»ÆäËû½ø³ÌËùÕ¾Óò»»áÊͷŵÄ×ÊÔ´¶ø´¦ÓÚµÄÒ»ÖÖÓÀ¾ÃµÈ´ý״̬¡£
ËÀËøµÄËĸö±ØÒªÌõ¼þ£º
»¥³âÌõ¼þ(Mutual exclusion)£º×ÊÔ´²»Äܱ»¹²Ïí£¬Ö»ÄÜÓÉÒ»¸ö½ø³ÌʹÓá£
ÇëÇóÓë±£³ÖÌ ......
ÓÉÓÚÖÖÖÖÔÒò£¬ÎÒÃÇÈç¹ûµ±Ê±½ö½ö±¸·ÝÁËmdfµµ£¬ÄÇô»Ö¸´ÆðÀ´¾ÍÊÇÒ»¼þºÜÂé·³µÄÊÂÇéÁË¡£
Èç¹ûÄúµÄmdfµµÊǵ±Ç°×ÊÁÏ¿â²úÉúµÄ£¬ÄÇôºÜ½ÄÐÒ£¬Ò²ÐíÄãʹÓÃsp_attach_db»òÕßsp_attach_single_file_db¿ÉÒÔ»Ö¸´×ÊÁϿ⣬µ«ÊÇ»á³öÏÖÀàËÆÏÂÃæµÄÌáʾ×ÊѶ
É豸Æô¶¯´íÎó¡£ÎïÀíµµ°¸Ãû 'C:\Program Files\Microsoft SQL S ......
1. ¿ÉÒÔÓýű¾±¸·Ý
¡¡¡¡manger studio--ÓÒ¼üÄãµÄÊý¾Ý¿â--ÈÎÎñ--Éú³É½Å±¾
¡¡¡¡Ôڽű¾Éú³ÉÏòµ¼µÄ"Ñ¡Ôñ¶ÔÏóÀàÐÍ"²½ÖèÖÐ, ½«"´æ´¢¹ý³Ì"Ñ¡ÉÏ, ÔÚ½ÓÏÂÀ´µÄ"Ñ¡Ôñ´æ´¢¹ý³Ì"µÄ²½ÖèÖÐ, Ñ¡ÔñËùÓеĴ洢¹ý³Ì(»òÕßÄãÒª¸´ÖƵĴ洢¹ý³Ì)
¡¡¡¡Íê³Éºó, ËùÓд洢¹ý³ÌµÄ½Å±¾»áÉú³ÉÔÚÒ»¸öеIJéѯ´°¿ÚÖÐ, ¹ØµôÉú³É½Å±¾Ïòµ¼, ÔÚÉú³ÉµÄ´æ´¢¹ý³Ì ......
--select name from sysobjects where type='U' order by name
SELECT
(case when a.colorder=1 then d.name else '' end) ±íÃû,
-- a.colorder ×Ö¶ÎÐòºÅ,
a.name ×Ö¶ÎÃû,
(case when COLUMNPROPERTY( a.id,a.name,'IsIdentity')=1 then '√'else '' end) ±êʶ,
(case when (SELECT count(* ......