{"id":98,"date":"2012-10-05T07:05:00","date_gmt":"1970-01-01T00:00:00","guid":{"rendered":"http:\/\/www.yazilimmutfagi.com\/?p=98"},"modified":"2012-10-05T07:05:00","modified_gmt":"1970-01-01T00:00:00","slug":"tsql-ile-belirli-bir-sayi-veya-tarih-araliginda-bir-seri-uretmek","status":"publish","type":"post","link":"https:\/\/www.yazilimmutfagi.com\/index.php\/2012\/10\/05\/tsql-ile-belirli-bir-sayi-veya-tarih-araliginda-bir-seri-uretmek\/","title":{"rendered":"TSQL ile Belirli bir Sayi veya Tarih Araliginda Bir Seri \u00dcretmek"},"content":{"rendered":"<p>TSQL de With kullanarak belirli sayida elemani olan bir seri olusturabilirsiniz. &Ouml;rnegin 1 den baslayarak 1000&#8217;e kadar olan integer sayilardan olusan bir seri olusturmak istiyorsaniz asagidaki scripti kullanabilirsiniz<\/p>\n<p>&nbsp;<\/p>\n<h3>Integer-Serisi<\/h3>\n<pre class=\"brush:sql\">\nWITH T(ID) AS\n(\n    SELECT 1 ID\n    UNION ALL SELECT ID + 1\n    FROM T\n    WHERE ID &lt; 1000\n)\nSELECT * FROM T\nOPTION (MAXRECURSION 1000)\n\n<\/pre>\n<a href='www.yazilimmutfagi.com'>.<\/a>\n<p>Eger bir tarihten baslayarak belirli bir tarihe kadar olan t&uuml;m g&uuml;nleri barindiran bir seri olusturmak istersek bu sefer asagidaki gibi bir script kullanmamiz gerekir.<\/p>\n<p>Asagidaki script 2011.01.01 tarihinden itibaren tarihe 1 g&uuml;n ekleyerek bugune kadar t&uuml;m tarihleri olusturur. maxrecursion 1000 diyerek ise en fazla 1000 tane olustur demis oluyoruz. 2011.01.01 den g&uuml;n&uuml;m&uuml;ze(2012.10.05) yaklasik 645 g&uuml;n oldugu i&ccedil;in max recursion sayisina ulasamayiz. Eger bu degeri d&uuml;zgn vermez isek asagidaki hatayi aliriz.<\/p>\n<p>Msg 530, Level 16, State 1, Line 1 <br \/>\nThe statement terminated. The maximum recursion 1000 has been exhausted before statement completion.<\/p>\n<h3>Iki Tarih Arasindaki t&uuml;m G&uuml;nler i&ccedil;in Seri Olusturmak<\/h3>\n<pre class=\"brush:sql\">\nWITH T(Date) AS\n(\n    SELECT CONVERT(datetime, '20110101') Date\n    UNION ALL \n    SELECT DATEADD(dd, 1, Date)\n    FROM T\n    WHERE Date &lt; GETDATE()\n)\nSELECT * FROM T\nOPTION (MAXRECURSION 1000)\n<\/pre>","protected":false},"excerpt":{"rendered":"<p>TSQL de With kullanarak belirli sayida elemani olan bir seri olusturabilirsiniz. &#214;rnegin 1 den baslayarak 1000&#39;e kadar olan integer sayilardan olusan bir seri olusturmak istiyorsaniz asagidaki scripti kullanabilirsiniz<\/p>\n","protected":false},"author":517,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[422],"tags":[5047,4478,4296],"_links":{"self":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/98"}],"collection":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/users\/517"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/comments?post=98"}],"version-history":[{"count":0,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/posts\/98\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/media?parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/categories?post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yazilimmutfagi.com\/index.php\/wp-json\/wp\/v2\/tags?post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}