{"id":1991,"date":"2011-10-06T23:04:37","date_gmt":"2011-10-06T15:04:37","guid":{"rendered":"http:\/\/jason695.why3s.tw\/wordpress\/?p=1991"},"modified":"2011-10-06T23:06:55","modified_gmt":"2011-10-06T15:06:55","slug":"%e8%bd%89%e8%b2%bcms-sql-%e7%94%a2%e7%94%9f-%e6%97%a5%e6%9c%9f%e5%8f%8a%e6%98%9f%e6%9c%9f","status":"publish","type":"post","link":"https:\/\/jason695.why3s.tw\/wordpress\/2011\/10\/06\/%e8%bd%89%e8%b2%bcms-sql-%e7%94%a2%e7%94%9f-%e6%97%a5%e6%9c%9f%e5%8f%8a%e6%98%9f%e6%9c%9f\/","title":{"rendered":"[\u8f49\u8cbc]MS-SQL \u7522\u751f \u65e5\u671f\u53ca\u661f\u671f"},"content":{"rendered":"<p><a id=\"viewpost_ascx_TitleUrl\" href=\"http:\/\/www.dotblogs.com.tw\/neilfan\/archive\/2011\/10\/06\/39061.aspx\">\u539f\u6587\u7db2\u5740<\/a><\/p>\n<pre lang=\"SQL\">---#### \u8a2d\u5b9a\u6bcf\u5468\u7684\u958b\u59cb\u662f\u661f\u671f\u5e7e\r\nSET DATEFIRST 1\r\n\r\nDECLARE @STARTDATE DATETIME,\r\n@ENDDATE DATETIME;\r\n\r\n---#### \u8a2d\u5b9a\u8981\u7522\u751f\u65e5\u671f\u7684\u5340\u9593\r\nSELECT @STARTDATE = SUBSTRING(CONVERT(varchar(8),GETDATE(),112),1,6) + '01',\r\n@ENDDATE = CONVERT(VARCHAR(8),DATEADD(dd,-1,DATEADD(mm,DATEDIFF(m,0,GETDATE())+1,0)),112);\r\n---#### \u7522\u751f\u65e5\u671f\u8ddf\u661f\u671f\r\n\r\n;WITH CTETABLE AS (\r\nSELECT [Date] = @STARTDATE\r\nUNION all\r\nSELECT [Date] + 1 FROM CTETABLE WHERE ([Date] &lt; @ENDDATE)\r\n)\r\nSELECT\r\nCONVERT(VARCHAR(8),[Date],112) AS [Date],\r\nCASE datepart(DW, [DATE])\r\nWHEN '1' THEN '\u661f\u671f\u4e00'\r\nWHEN '2' THEN '\u661f\u671f\u4e8c'\r\nWHEN '3' THEN '\u661f\u671f\u4e09'\r\nWHEN '4' THEN '\u661f\u671f\u56db'\r\nWHEN '5' THEN '\u661f\u671f\u4e94'\r\nWHEN '6' THEN '\u661f\u671f\u516d'\r\nWHEN '7' THEN '\u661f\u671f\u65e5' END AS [WeekDay]\r\nFROM CTETABLE<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u539f\u6587\u7db2\u5740 &#8212;#### \u8a2d\u5b9a\u6bcf\u5468\u7684\u958b\u59cb\u662f\u661f\u671f\u5e7e SET DATEFIRST 1 DECLARE @START &hellip; <a href=\"https:\/\/jason695.why3s.tw\/wordpress\/2011\/10\/06\/%e8%bd%89%e8%b2%bcms-sql-%e7%94%a2%e7%94%9f-%e6%97%a5%e6%9c%9f%e5%8f%8a%e6%98%9f%e6%9c%9f\/\" class=\"more-link\">\u95b1\u8b80\u5168\u6587 <span class=\"screen-reader-text\">[\u8f49\u8cbc]MS-SQL \u7522\u751f \u65e5\u671f\u53ca\u661f\u671f<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[47],"tags":[],"class_list":["post-1991","post","type-post","status-publish","format-standard","hentry","category-sql-server","no-featured-image"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/1991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/comments?post=1991"}],"version-history":[{"count":0,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/posts\/1991\/revisions"}],"wp:attachment":[{"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/media?parent=1991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/categories?post=1991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jason695.why3s.tw\/wordpress\/wp-json\/wp\/v2\/tags?post=1991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}