{"id":325,"date":"2010-10-01T01:55:25","date_gmt":"2010-10-01T01:55:25","guid":{"rendered":"http:\/\/enjoyasp.net\/?p=325"},"modified":"2010-10-01T01:55:25","modified_gmt":"2010-10-01T01:55:25","slug":"sql%e8%af%ad%e5%8f%a5%e5%9c%a8sql-server%e6%89%a7%e8%a1%8c%e9%80%9f%e5%ba%a6%e5%be%88%e5%bf%ab%ef%bc%8c1%e5%88%b02%e7%a7%92%ef%bc%8c%e8%80%8c%e7%94%a8web%e8%bf%9e%e6%8e%a5%e8%8e%b7%e5%8f%96%e6%95%b0","status":"publish","type":"post","link":"https:\/\/enjoyasp.net\/index.php\/2010\/10\/01\/sql%e8%af%ad%e5%8f%a5%e5%9c%a8sql-server%e6%89%a7%e8%a1%8c%e9%80%9f%e5%ba%a6%e5%be%88%e5%bf%ab%ef%bc%8c1%e5%88%b02%e7%a7%92%ef%bc%8c%e8%80%8c%e7%94%a8web%e8%bf%9e%e6%8e%a5%e8%8e%b7%e5%8f%96%e6%95%b0\/","title":{"rendered":"sql\u8bed\u53e5\u5728Sql Server\u6267\u884c\u901f\u5ea6\u5f88\u5feb\uff0c1\u52302\u79d2\uff0c\u800c\u7528web\u8fde\u63a5\u83b7\u53d6\u6570\u636e\uff0c\u603b\u662ftimeout"},"content":{"rendered":"<p>\u89e3\u51b3\u65b9\u6cd5\uff1a<br \/>\n1\uff0c\u4f18\u5316sql\u8bed\u53e5\u3002<br \/>\n2\uff0c\u5c06sql\u8bed\u53e5\u5229\u7528\u5b57\u7b26\u4e32\u6784\u9020\uff0c\u5bf9\u4e8e\u4ece\u51e0\u767e\u4e2a\u4ee5\u4e0a\u7684\u6570\u636e\u4e2d\u53d6\u51fa\u51e0\u4e2a\u503c\u6765\u8bf4\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u503c\u53d6\u51fa\u3002<br \/>\n\u5373\uff1a\u5f53\u4f7f\u7528exists\u6216in\u65f6\uff0c\u82e5\u771f\u6b63\u7684\u6570\u636e\u5360\u8868\u4e2d\u7684\u6bd4\u4f8b\u5c0f\u4e8e10%,\u53ef\u4ee5\u5168\u90e8\u53d6\u51fa\uff0c\u6784\u9020sql\u8bed\u53e5\u5904\u7406\u3002<br \/>\nDECLARE @Query VARCHAR(500)<br \/>\n    SET @Query = &#8221;<br \/>\n    SET @Query = &#8216;<br \/>\n    SELECT ISNULL(COUNT(1),0) as SalesCount, ISNULL(sum(b.Cash), 0) as Amount<br \/>\n    FROM bdOrder a(NOLOCK)<br \/>\n    JOIN bdAchievement b(NOLOCK)<br \/>\n    ON a.Orderno = b.Orderno<br \/>\n    WHERE OrderDate >=&#8221;&#8217; + CONVERT(VARCHAR(10),@OrderDate) + &#8221;&#8217;  &#8216; + &#8216; AND OrderDate < ''' + CONVERT(VARCHAR(10),Dateadd(day, 1, @OrderDate),120) + ''''  \n     + ' And OrderStatus NOT IN (''01'', ''61'',''04'',''21'',''22'')'\n     \n     DECLARE @DepartmentIDS VARCHAR(500) \/\/\u5b58\u50a8\u5c0f\u8303\u56f4\u7684\u6570\u636e\n     SET @DepartmentIDS = ''\n     SELECT @DepartmentIDS = @DepartmentIDS + ',' + CONVERT(VARCHAR(4),pdr.SlaveDepartmentID) \n     FROM permDepartmentRelation pdr WHERE pdr.MasterDepartment = @DepartmentID\n     IF (@DepartmentIDS <> &#8221;)<br \/>\n     BEGIN<br \/>\n         SET @DepartmentIDS = SUBSTRING(@DepartmentIDS,2,len(@DepartmentIDS))<br \/>\n     END<br \/>\n     SET @Query = @Query + &#8216; AND b.DepartmentID IN(&#8216; + @DepartmentIDS + &#8216;)&#8217;<\/p>\n<p>     EXEC(@Query)<\/p>\n<p>3\uff0c\u82e5\u5229\u7528\u4e86join,\u4e14where\u4e2d\u6709\u6761\u4ef6\u5bf9\u8fd9\u4e2a\u8fde\u63a5\u8868\u8fdb\u884c\u7b5b\u9009\uff0c\u5219\u53ef\u5c06\u6761\u4ef6\u76f4\u63a5\u653e\u5728join\u65f6\u8fdb\u884c\u7b5b\u9009\uff0c\u4ee5\u51cf\u5c11IO\u541e\u5410\u3002<br \/>\n\u5373\uff1a\u5229\u7528join\u65f6\uff0cwhere\u4e2d\u7684\u6761\u4ef6\u4e3b\u8981\u9488\u5bf9\u4e8e\u4e3b\u8868\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u51b3\u65b9\u6cd5\uff1a 1\uff0c\u4f18\u5316sql\u8bed\u53e5\u3002 2\uff0c\u5c06sql\u8bed\u53e5\u5229\u7528\u5b57\u7b26\u4e32\u6784\u9020\uff0c\u5bf9\u4e8e\u4ece\u51e0\u767e\u4e2a\u4ee5\u4e0a\u7684\u6570\u636e\u4e2d\u53d6\u51fa\u51e0\u4e2a\u503c\u6765\u8bf4\uff0c\u53ef\u4ee5 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"class_list":["post-325","post","type-post","status-publish","format-standard","hentry","category-13"],"blocksy_meta":[],"_links":{"self":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/comments?post=325"}],"version-history":[{"count":0,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/posts\/325\/revisions"}],"wp:attachment":[{"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/media?parent=325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/categories?post=325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enjoyasp.net\/index.php\/wp-json\/wp\/v2\/tags?post=325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}