{"id":776,"date":"2020-05-18T17:20:28","date_gmt":"2020-05-18T08:20:28","guid":{"rendered":"https:\/\/csharp.ihavenomoney.co.kr\/?p=776"},"modified":"2020-05-18T17:20:28","modified_gmt":"2020-05-18T08:20:28","slug":"ip-%ea%b5%ad%ea%b0%80-%eb%a6%ac%ec%8a%a4%ed%8a%b8-%ed%8e%b8%ed%95%98%ea%b8%b0-%ea%b2%80%ec%83%89%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/csharp.ihavenomoney.co.kr\/?p=776","title":{"rendered":"IP \uad6d\uac00 \ub9ac\uc2a4\ud2b8 \ud3b8\ud558\uae30 \uac80\uc0c9\ud558\uae30"},"content":{"rendered":"<p><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2020\/05\/ipv4.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2020\/05\/ipv4.jpg\" alt=\"\" width=\"770\" height=\"474\" class=\"alignnone size-full wp-image-777\" srcset=\"https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2020\/05\/ipv4.jpg 770w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2020\/05\/ipv4-300x185.jpg 300w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2020\/05\/ipv4-768x473.jpg 768w, https:\/\/csharp.ihavenomoney.co.kr\/wp-content\/uploads\/2020\/05\/ipv4-660x406.jpg 660w\" sizes=\"auto, (max-width: 770px) 100vw, 770px\" \/><\/a><\/p>\n<pre class=\"lang:tsql decode:true \" >USE [ipv]\r\nGO\r\n\r\n\/****** Object:  Table [dbo].[ipv4_KR]    Script Date: 2020-05-18 \uc624\ud6c4 5:12:30 ******\/\r\nSET ANSI_NULLS ON\r\nGO\r\n\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\n\r\nSET ANSI_PADDING ON\r\nGO\r\n\r\nCREATE TABLE [dbo].[ipv4_KR](\r\n\t[IDX] [int] NOT NULL,\r\n\t[Standard_Date] [varchar](20) NOT NULL CONSTRAINT [DF_ipv4_KR_Standard_Date]  DEFAULT (''),\r\n\t[Cuntry_Code] [varchar](10) NOT NULL CONSTRAINT [DF_ipv4_KR_Cuntry_Code]  DEFAULT (''),\r\n\t[Start_IP_Number] [float] NOT NULL CONSTRAINT [DF_ipv4_KR_Start_IP_Number]  DEFAULT ((0)),\r\n\t[End_IP_Number] [float] NOT NULL CONSTRAINT [DF_ipv4_KR_End_IP_Number]  DEFAULT ((0)),\r\n\t[Start_IP] [varchar](20) NOT NULL CONSTRAINT [DF_ipv4_KR_Start_IP]  DEFAULT (''),\r\n\t[End_IP] [varchar](20) NOT NULL CONSTRAINT [DF_ipv4_KR_End_IP]  DEFAULT (''),\r\n\t[PREFIX] [varchar](20) NOT NULL CONSTRAINT [DF_ipv4_KR_PREFIX]  DEFAULT (''),\r\n\t[Regi_Date] [varchar](20) NOT NULL CONSTRAINT [DF_ipv4_KR_Regi_Date]  DEFAULT (''),\r\n CONSTRAINT [PK_ipv4_KR] PRIMARY KEY CLUSTERED \r\n(\r\n\t[IDX] ASC\r\n)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]\r\n) ON [PRIMARY]\r\n\r\nGO\r\n\r\nSET ANSI_PADDING OFF\r\nGO\r\n<\/pre>\n<pre class=\"lang:tsql decode:true \" title=\"fn_GetIdxDataLikeSplit\" >-----------------------------------------------------------------------------------------------------------  \r\n--  Split \uc720\ud615\uc758 \ud568\uc218  \r\n--  \ubb38\uc790\uc5f4\uc5d0\uc11c \uad6c\ubd84\uc790(@iSeparator)\ub85c \uba87\ubc88\uc9f8 \ub2e8\uc5b4 \uac00\uc838\uc624\uae30  \r\n--  \uc608: SELECT \ub370\uc774\ud130\ubca0\uc774\uc2a4\uba85.\uc18c\uc720\uc790\uba85.fn_GetIdxDataLikeSplit('\uac00-\ub098-\ub2e4',2,'-') --&gt; '\ub098'  \r\n-----------------------------------------------------------------------------------------------------------  \r\n-----------------------------------------------------------------------------------------------------------  \r\n-- \ud504\ub85c\uc2dc\uc800 \uc0dd\uc131  \r\n-----------------------------------------------------------------------------------------------------------  \r\nAlter  FUNCTION  [dbo].[fn_GetIdxDataLikeSplit]   \r\n    (  \r\n        @iText          VARCHAR(200),  \r\n        @idx                INT,  \r\n        @iSeparator     VARCHAR(10) = '.'  \r\n    )  \r\nRETURNS  VARCHAR(200)   \r\nAS  \r\nBEGIN  \r\n    DECLARE @wData          VARCHAR(200)  \r\n    DECLARE @wText          VARCHAR(200)  \r\n    DECLARE @wSeparator VARCHAR(10)  \r\n    DECLARE @wNum           INT  \r\n  \r\n    SET @wData          = ''  \r\n    SET @wNum           = 1;  \r\n    SET @wSeparator = LTRIM(RTRIM(@iSeparator));  \r\n    SET @wText          = LTRIM(RTRIM(@iText)) + @wSeparator;   \r\n  \r\n    IF CHARINDEX(@wSeparator, @iText) &gt; 0  \r\n    BEGIN  \r\n        WHILE    @idx &gt;= @wNum  \r\n        BEGIN  \r\n            IF CHARINDEX(@wSeparator, @wText) &gt; 0  \r\n            BEGIN  \r\n                   -- \ubb38\uc790\uc5f4\uc758 \uc778\ub371\uc2a4 \uc704\uce58\uc758 \uc694\uc18c\ub97c \ubc18\ud658  \r\n                   SET @wData   = SUBSTRING(@wText, 1, CHARINDEX(@wSeparator, @wText) - 1);  \r\n                   SET @wData   = LTRIM(RTRIM(@wData));  \r\n  \r\n                -- \ubc18\ud658\ub41c \ubb38\uc790\ub294 \ubc84\ub9b0\ud6c4 \uc88c\uc6b0\uacf5\ubc31 \uc81c\uac70     \r\n                    SET @wText  = LTRIM(RTRIM(RIGHT(@wText, LEN(@wText) - (LEN(@wData) + LEN(@iSeparator)))))  \r\n            END   \r\n            ELSE  \r\n            BEGIN  \r\n                    SET @wData  = ''  \r\n            END  \r\n            SET @wNum = @wNum + 1  \r\n        END  \r\n    END  \r\n    ELSE  \r\n    BEGIN  \r\n        SET @wData  = @iText  \r\n    END  \r\n      -- HEO ADd\r\n    if Len(@wData) =1\r\n\t    begin Set @wData =  '00' + @wData   end  \r\n\telse if(Len(@wData) =2)\r\n\t    begin Set @wData =  '0' + @wData   end  \r\n\t  \r\n    RETURN(@wData)  \r\n      \r\nEND  <\/pre>\n<pre class=\"lang:tsql decode:true \" title=\"sp\" >Declare @IDX int\r\nDeclare @Start_IP varchar(20), @End_IP varchar(20)\r\n\r\nDeclare @Start_IP_01 varchar(3),@Start_IP_02 varchar(3),@Start_IP_03 varchar(3),@Start_IP_04 varchar(3)\r\nDeclare @End_IP_01 varchar(3),@End_IP_02 varchar(3),@End_IP_03 varchar(3),@End_IP_04 varchar(3)\r\n \r\nDeclare con_cursor cursor for SELECT IDX, Start_IP, End_IP  FROM [IBE_Basic_Code].[dbo].[ipv4_KR] \r\n\topen con_cursor --\ucee4\uc2a4\ub97c \uc5f0\ub2e4.\r\n\tfetch next from con_cursor into @IDX, @Start_IP, @End_IP\r\n\twhile (@@fetch_status &lt;&gt;-1)\r\n\t\tbegin\r\n\t\tif (@@fetch_status = -2)\r\n\t\tcontinue\r\n\t\t\tbegin\r\n\r\n\t\t\t   Set @Start_IP_01 = [dbo].[fn_GetIdxDataLikeSplit](@Start_IP,1,'.')\r\n\t\t\t   Set @Start_IP_02 = [dbo].[fn_GetIdxDataLikeSplit](@Start_IP,2,'.')\r\n\t\t\t   Set @Start_IP_03 = [dbo].[fn_GetIdxDataLikeSplit](@Start_IP,3,'.')\r\n\t\t\t   Set @Start_IP_04 = [dbo].[fn_GetIdxDataLikeSplit](@Start_IP,4,'.')\r\n\t\t\t   \r\n\t\t\t   Set @End_IP_01 = [dbo].[fn_GetIdxDataLikeSplit](@End_IP,1,'.')\r\n\t\t\t   Set @End_IP_02 = [dbo].[fn_GetIdxDataLikeSplit](@End_IP,2,'.')\r\n\t\t\t   Set @End_IP_03 = [dbo].[fn_GetIdxDataLikeSplit](@End_IP,3,'.')\r\n\t\t\t   Set @End_IP_04 = [dbo].[fn_GetIdxDataLikeSplit](@End_IP,4,'.')\r\n\r\n\r\n\t\t\t   update [IBE_Basic_Code].[dbo].[ipv4_KR] set Start_IP_Number = CONVERT(numeric, @Start_IP_01 +  @Start_IP_02 + @Start_IP_03 + @Start_IP_04)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t  ,End_IP_Number = CONVERT(numeric, @End_IP_01 +  @End_IP_02 + @End_IP_03 + @End_IP_04)\r\n\t\t\t   where IDX = @IDX\r\n\r\n\r\n\r\n\t\t\t   \r\n\t\t\tend\r\n\t\tfetch next from con_cursor into @IDX, @Start_IP, @End_IP\r\n\t\tend\r\n\tclose con_cursor\r\nDeallocate con_cursor<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>USE [ipv] GO \/****** Object: Table [dbo].[ipv4_KR] Script Date: 2020-05-18 \uc624\ud6c4 5:12:30 ******\/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING ON GO CREATE TABLE [dbo].[ipv4_KR]( [IDX] [int] NOT NULL, [Standard_Date] [varchar](20) NOT NULL CONSTRAINT [DF_ipv4_KR_Standard_Date] DEFAULT (&#8221;), [Cuntry_Code] [varchar](10) NOT NULL CONSTRAINT [DF_ipv4_KR_Cuntry_Code] DEFAULT (&#8221;), [Start_IP_Number] [float] NOT NULL CONSTRAINT [DF_ipv4_KR_Start_IP_Number] DEFAULT\u2026 <span class=\"read-more\"><a href=\"https:\/\/csharp.ihavenomoney.co.kr\/?p=776\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-776","post","type-post","status-publish","format-standard","hentry","category-1"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=776"}],"version-history":[{"count":1,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/776\/revisions"}],"predecessor-version":[{"id":778,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/776\/revisions\/778"}],"wp:attachment":[{"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/csharp.ihavenomoney.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}