{"id":296,"date":"2011-06-25T01:51:57","date_gmt":"2011-06-24T20:51:57","guid":{"rendered":"http:\/\/kennywu.info\/?p=296"},"modified":"2011-07-04T18:48:33","modified_gmt":"2011-07-04T13:48:33","slug":"a-simple-sqll-cursor-sample","status":"publish","type":"post","link":"http:\/\/kennywu.info\/?p=296","title":{"rendered":"A simple Sql cursor sample"},"content":{"rendered":"<p><code><br \/>\nUSE FencoDW<br \/>\nGO<\/p>\n<p>DECLARE @ID INT, @PR varchar(50)<br \/>\nDECLARE @getID CURSOR<br \/>\nSET @getID = CURSOR FOR<br \/>\nSELECT [Load Number], [Primary Reference(s)]<br \/>\nFROM Accounting.TransplaceLoadInfo<\/p>\n<p>OPEN @getID<br \/>\nFETCH NEXT<br \/>\nFROM @getID INTO @ID, @PR<br \/>\nWHILE @@FETCH_STATUS = 0<br \/>\nBEGIN<br \/>\n\tPRINT @ID<br \/>\n\tPRINT @PR<\/p>\n<p>\tINSERT INTO dbo.T1 ([Load Number], [Primary Reference(s)])<br \/>\n\tSELECT @ID, [Val] from dbo.ParseCSV(@PR, ',')<\/p>\n<p>\tFETCH NEXT<br \/>\n\tFROM @getID INTO @ID, @PR<br \/>\nEND<br \/>\n CLOSE @getID<br \/>\nDEALLOCATE @getID<br \/>\nGO<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>USE FencoDW GO DECLARE @ID INT, @PR varchar(50) DECLARE @getID CURSOR SET @getID = CURSOR FOR SELECT [Load Number], [Primary Reference(s)] FROM Accounting.TransplaceLoadInfo OPEN @getID FETCH NEXT FROM @getID INTO @ID, @PR WHILE @@FETCH_STATUS = 0 BEGIN PRINT @ID PRINT &hellip; <a href=\"http:\/\/kennywu.info\/?p=296\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[71],"class_list":["post-296","post","type-post","status-publish","format-standard","hentry","category-database","tag-cursor"],"_links":{"self":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/296","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=296"}],"version-history":[{"count":3,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/296\/revisions"}],"predecessor-version":[{"id":303,"href":"http:\/\/kennywu.info\/index.php?rest_route=\/wp\/v2\/posts\/296\/revisions\/303"}],"wp:attachment":[{"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=296"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=296"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/kennywu.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=296"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}