|
9°. ºñÁ¤±ÔÅ×À̺íÀÇ Á¤±ÔÈ - 1
ÀÌ¹Ì Á¤±ÔÈ µÇ¾î ÀÖÁö ¾ÊÀº Å×ÀÌºí¿¡ ÀÚ·á°¡ µé¾î ÀÖ´Â °æ¿ì Á¦1 Á¤±ÔÇü Å×À̺í·Î ¸¸µå´Â ÀÛ¾÷À» ÇØ¾ß ÇÒ °æ¿ì°¡ Á¾Á¾ ÀÖ½À´Ï´Ù. ´ëÇ¥ÀûÀÎ ¿¹·Î ¼³¹®Á¶»ç¸¦ µé ¼ö ÀÖ½À´Ï´Ù. ´ë°³ ¿¢¼¿À» ÀÌ¿ëÇÏ¿© ¼ö¸¹Àº ¼³¹®Á¶»ç Ç׸ñÀ» °¢°¢ÀÇ ¿·Î ³ª¿ÇÏ°í ¼³¹®Á¶»ç ³»¿ëÀ» Á¿ì·Î ¿Å°Ü´Ù´Ï¸é¼ ÀÔ·ÂÇÏ´õ±º¿ä. ¿¢¼¿ÀÇ °£´ÜÇÑ µ¥ÀÌÅͺ£À̽º ±â´ÉÀ» ÀÌ¿ëÇϱ⵵ ÇÏÁö¸¸ ±×·¯³ª ¾×¼¼½º¸¦ ÀÌ¿ëÇÏ¿© °ü¸®ÇÑ´Ù¸é ÈξÀ ¼Õ½±°Ô ÇÒ ¼ö ÀÖ½À´Ï´Ù.
ÀÌÀü °Á¿¡¼ ¿Ã¸° ¿¹Á¦ ÆÄÀÏ¿¡¼ °í°´Á¤º¸¿¡ ´ëÇÑ Å×À̺íÀ» °¡Áö°í °»½Å(¾÷µ¥ÀÌÆ®)ÁúÀÇ¿Í Å×À̺íÀÛ¼º ÁúÀǸ¦ ÀÌ¿ëÇÏ¿© Á¤±ÔÇü Å×À̺í·Î ¸¸µå´Â ¹æ¹ýÀ» ¼³¸íÇϵµ·Ï ÇÏ°Ú½À´Ï´Ù.
ÀÌ ³»¿ëÀº Ãʺ¸Àڵ鿡°Ô´Â Á¶±Ý ¾î·Á¿ï °ÍÀ¸·Î »ý°¢µË´Ï´Ù. ¹°·Ð °Ç³Ê ¶Ù¾îµµ µË´Ï´Ù.
ÃÖ¼Ò Á¤º¸ ´ÜÀ§·Î ÂÉ°³±â
1. '°í°´Á¤º¸-ºñÁ¤±ÔÈ' Å×À̺íÀ» º¹»çÇÏ¿© '°í°´Á¤º¸' Å×À̺í·Î ÀúÀåÇÕ´Ï´Ù.
2. ÀúÀåµÈ °í°´Á¤º¸ Å×À̺íÀ» µðÀÚÀÎ º¸±â·Î ¿¾î ´ÙÀ½°ú °°ÀÌ Å×ÀÌºí ±¸Á¶¸¦ ¼öÁ¤ÇÕ´Ï´Ù.
±×¸®°í ¼öÁ¤µÈ Å×À̺íÀ» º¹»çÇؼ '°í°´Á¤º¸-¼öÁ¤º»' À̶ó´Â À̸§À¸·Î ¹é¾÷ÇØ µÓ´Ï´Ù.
Çʵå¸í
|
Çü½Ä
|
Å©±â
|
CustomerID
|
Text
|
5
|
CompanyName
|
Text
|
40
|
ContactName
|
Text
|
20
|
ContactTitle
|
Text
|
30
|
Address
|
Text
|
100
|
City
|
Text
|
15
|
Region
|
Text
|
15
|
PostalCode
|
Text
|
10
|
Country
|
Text
|
15
|
Phone
|
Text
|
100
|
Fax
|
Text
|
24
|
3. ºó ÁúÀÇÅ×À̺íÀ» Çϳª ¸¸µì´Ï´Ù.
ÁúÀÇÅ×ÀÌºí ¸¶¹ý»ç¿¡ ´ëÇؼ´Â µµ¿ò¸»À̳ª ¹«·á°Á¸¦ ã¾Æº¸½Ã¸é ÀÖÀ» °Ì´Ï´Ù.
1) <ÁúÀÇ »õ·Î ¸¸µé±â>¸¦ ÇÏ°í µðÀÚÀÎ º¸±â¸¦ ¼±ÅÃÇÑ ´ÙÀ½ Å×À̺íÀ» Ãß°¡ÇÏÁö ¾ÊÀº ºó ÁúÀÇÅ×À̺íÀ» Çϳª ¸¸µì´Ï´Ù.
2) µµ±¸¸ðÀ½ ¸Þ´º¿¡¼ SQLº¸±â¸¦ Ŭ¸¯ÇÏ¿© SQLâÀ» ¿±´Ï´Ù.
¾÷µ¥ÀÌÆ® ÁúÀÇ ÀÌ¿ë
ÁÖÀÇ > ¾Æ·¡ÀÇ °»½Å ÁúÀÇ´Â Çѹø¸¸ ½ÇÇàÇØ¾ß ÇÕ´Ï´Ù. µÎ ¹ø ½ÇÇàÇϸé ÇÊµå ³»¿ëÀÌ Áö¿öÁý´Ï´Ù. ¹°·Ð ±×·¸°Ô µÇÁö ¾Êµµ·Ï ÇÒ ¼ö ÀÖÁö¸¸ ÀÌ·¯ÇÑ ½ÇÇàÁúÀÇ´Â Ç×»ó Á¶½ÉÇØ¾ß ÇÔÀ» ¸í½É½ÃÅ°±â À§ÇÑ °ÍÀÔ´Ï´Ù. ±×·± °æ¿ì À§¿¡¼ ¸¸µé¾î µÐ '°í°´Á¤º¸-¼öÁ¤º»' ÆÄÀÏÀ» º¹»çÇÏ¿© '°í°´Á¤º¸' Å×À̺í·Î ÀúÀåÇÏ¸é µË´Ï´Ù.
1. ´ã´çÀÚ Çʵ带 ´ã´çÀÚ À̸§°ú Á÷À§·Î ³ª´©±â
À§¿Í °°Àº ¹æ¹ýÀ¸·Î ºó ÁúÀÇÅ×À̺íÀ» ¸¸µé°í SQLâÀ» ¿¬ ´ÙÀ½ ´ÙÀ½¿¡ ÀûÈù ÁúÀǹ®À» º¹»çÇØ ³ÖÀº ´ÙÀ½ 'Á¦1Á¤±ÔÈ-´ã´çÀÚ Query' À̸§À¸·Î ÀúÀåÇÕ´Ï´Ù.
UPDATE °í°´Á¤º¸
SET °í°´Á¤º¸.ContactName = Left([ContactName],InStr([ContactName],"(")-1),
°í°´Á¤º¸.ContactTitle = Mid([ContactName], InStr([ContactName],"(")+1, Len([ContactName])-InStr([ContactName],"(")-1); |
2. µðÀÚÀÎ º¸±â·Î ÀüȯÇÏ¸é ´ÙÀ½°ú °°ÀÌ º¸ÀÔ´Ï´Ù. ¾Æ·¡ ³ª¸ÓÁö ÁúÀÇÅ×À̺í·Î SQLâ¿¡ ÁúÀǹ®À» ÀÔ·ÂÇÏ°í µðÀÚÀÎ º¸±â·Î ÀüȯÇÏ¿© Çѹø¾¿ º¸½Ê½Ã¿À.
3. ÁÖ¼Ò Çʵ带 ³ª´©±â
°°Àº ¹æ¹ýÀ¸·Î ÁúÀÇÅ×À̺íÀ» Çϳª ¸¸µé°í ´ÙÀ½ SQLâÀ» ¿°í ´ÙÀ½ÀÇ ÁúÀǹ®À» º¹»çÇØ ³ÖÀº ´ÙÀ½ 'Á¦1Á¤±ÔÈ-ÁÖ¼Ò Query' À̸§À¸·Î ÀúÀåÇÕ´Ï´Ù. ¿©±â¼´Â ÁúÀÇ¿¡ »ç¿ëÀÚ Á¤ÀÇÇÔ¼ö¸¦ »ç¿ëÇÕ´Ï´Ù. VBA¸ðµâ¿¡¼
SplitAddress() »ç¿ëÀÚ Á¤ÀÇ ÇÔ¼ö¸¦ È®ÀÎÇϽʽÿÀ.
UPDATE °í°´Á¤º¸
SET °í°´Á¤º¸.Region = SplitAddress([Address],"µµ"),
°í°´Á¤º¸.City = SplitAddress([Address],"½Ã"),
°í°´Á¤º¸.Address = SplitAddress([Address],"µ¿¸®"),
°í°´Á¤º¸.PostalCode = SplitAddress([Address],"¿ìÆí¹øÈ£"); |
4. ÀüȹøÈ£ Çʵ带 ³ª´©±â
ÁúÀÇÅ×À̺íÀ» Çϳª ¸¸µé°í ´ÙÀ½ ÁúÀǹ®À» º¹»çÇØ ³ÖÀº ´ÙÀ½ 'Á¦1Á¤±ÔÈ-ÀüÈ Query' À̸§À¸·Î ÀúÀåÇÕ´Ï´Ù.
UPDATE °í°´Á¤º¸
SET °í°´Á¤º¸.Phone = Left([Phone],InStr([Phone],",")-1),
°í°´Á¤º¸.Fax = Trim(Mid([Phone],InStr([Phone],",")+1)); |
5. ÀÌÁ¦ ÁúÀǸ¦ ½ÇÇà½ÃÅ°¸é µË´Ï´Ù. ÁúÀǸ¦ ½ÇÇà ½Ãų ¶§´Â ÁúÀÇ µðÀÚÀÎ ¸ðµå¿¡¼ ¸Þ´º¿¡¼ ÁúÀǽÇÇà ¹öÆ°
À» Ŭ¸¯Çϰųª [F11] Å°¸¦ ´·¯ µ¥ÀÌÅͺ£À̽º âÀ» ºÒ·¯³½ ´ÙÀ½ ¹æ±Ý ÀúÀåÇÑ ÁúÀÇÅ×ÀÌºí °³Ã¼¸¦ ´õºí Ŭ¸¯ÇÏ¸é ¿øÇÏ´Â °»½ÅÀÛ¾÷ÀÌ ÀÌ·ç¾î Áý´Ï´Ù.
ÁÖÀÇ > Çѹø¸¸ ½ÇÇàÇØ¾ß ÇÕ´Ï´Ù. µÎ ¹ø ½ÇÇàÇϸé ÇÊµå ³»¿ëÀÌ Áö¿öÁý´Ï´Ù. ¸¸¾à ¿À·ù°¡ ¹ß»ýÇϸé ÀÌÀü¿¡ ¸¸µé¾î µÐ '°í°´Á¤º¸-¼öÁ¤º»' ÆÄÀÏÀ» º¹»çÇÏ¿© '°í°´Á¤º¸' Å×À̺í·Î ÀúÀåÇÏ¸é µË´Ï´Ù.
6. °á°ú´Â ´ÙÀ½°ú °°½À´Ï´Ù.
7. ºñ¾î ÀÖ´Â ±¹°¡¸í Çʵ忡´Â '´ëÇѹα¹'À¸·Î ä¿ö ³Öµµ·Ï ÇÕ´Ï´Ù. ¿ª½Ã ¾Õ¼ Çß´ø ´ë·Î 'ÁúÀÇ »õ·Î ¸¸µé±â'¸¦ Ŭ¸¯ÇÑ ´ÙÀ½ SQLâ¿¡ ´ÙÀ½ ÁúÀǸ¦ ³Ö°í ½ÇÇàÇÏ¸é µÇ°Ú½À´Ï´Ù.
UPDATE °í°´Á¤º¸ SET °í°´Á¤º¸.Country = "´ëÇѹα¹";
Å×ÀÌºí »ý¼º ÁúÀÇ ÀÌ¿ë
1. ÁúÀÇ »õ·Î ¸¸µé±â¿¡¼ µðÀÚÀÎ º¸±â·Î ºó ÁúÀǸ¦ ¸¸µì´Ï´Ù.
2. ÁúÀǵðÀÚÀÎ µµ±¸¸ðÀ½ ¸Þ´º¿¡¼ SQLº¸±â ¸Þ´º¸¦ Ŭ¸¯ÇÏ¿© SQLâÀÌ ¶ß¸é ´ÙÀ½ ³»¿ëÀ» º¹»çÇØ ³Ö°í µðÀÚÀÎ º¸±â/µ¥ÀÌÅͽÃÆ® º¸±â·Î ÀüȯÇÏ¿© È®ÀÎÇÏ°í ³ª¼ ¿ª½Ã ½ÇÇà¹öÆ°À» ´·¯ ½ÇÇà½ÃÅ°¸é »õ·Î¿î Å×À̺íÀÌ ¸¸µé¾î Áý´Ï´Ù.
SELECT °í°´Á¤º¸_ºñÁ¤±ÔÈ.CustomerID,
°í°´Á¤º¸_ºñÁ¤±ÔÈ.CompanyName,
Left([ContactName],InStr([ContactName],"(")-1) AS ContactName2,
Mid([ContactName],InStr([ContactName],"(")+1,Len([ContactName])-InStr([ContactName],"(")-1)
AS ContactTitle,
Left([Phone],InStr([Phone],",")-1) AS Phone2,
Trim(Mid([Phone],InStr([Phone],",")+1)) AS
Fax,
SplitAddress([Address],"µµ") AS Region,
SplitAddress([Address],"½Ã") AS City,
SplitAddress([Address],"µ¿") AS Address2,
SplitAddress([Address],"¿ìÆí¹øÈ£") AS PostalCode,
"´ëÇѹα¹" AS Country
INTO °í°´Á¤º¸_2
FROM °í°´Á¤º¸_ºñÁ¤±ÔÈ; |
´ÙÀ½ °Á¿¡´Â ¼³¹®Áö Å×À̺íÀ» ¿¹Á¦·Î Á¤±ÔÈÇÏ´Â
°ÍÀ» ¾Ë¾Æ º¸µµ·Ï ÇÏ°Ú½À´Ï´Ù.
|