{"id":450,"date":"2014-01-21T10:00:22","date_gmt":"2014-01-21T19:00:22","guid":{"rendered":"\/blog\/?p=450"},"modified":"2023-09-21T09:38:47","modified_gmt":"2023-09-21T00:38:47","slug":"ms-sql-%ec%82%ac%ec%9a%a9%ec%9e%90-%ec%a0%95%ec%9d%98-%ed%95%a8%ec%88%98-%eb%a7%8c%eb%93%a4%ea%b8%b0","status":"publish","type":"post","link":"https:\/\/hasu0707.duckdns.org\/blog\/?p=450","title":{"rendered":"MS-SQL \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218 \ub9cc\ub4e4\uae30"},"content":{"rendered":"\n<div class=\"introduction\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><p>\uc6d0\ubb38 : <a class=\"tx-link\" target=\"_blank\" href=\"http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx\" rel=\"noopener\">http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx<\/a><br \/><\/p><p><span style=\"font-size: 9pt; font-family: Courier New;\"><br \/>\n            <\/span><span id=\"mt1\" class=\"sentence\" data-guid=\"5cfdfd1dff4a46bc3367553f029c0f3c\" data-source=\"This topic describes how to create a Transact-SQL user-defined function in SQL Server 2012 by using Transact-SQL.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc774 \ud56d\ubaa9\uc5d0\uc11c\ub294 Transact-SQL\uc744 \uc0ac\uc6a9\ud558\uc5ec SQL Server 2012\uc5d0\uc11c Transact-SQL \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub97c \ub9cc\ub4dc\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574 \uc124\uba85\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"label\">\ud56d\ubaa9 \ub0b4\uc6a9<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><ul><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"label\">\uc2dc\uc791\ud558\uae30 \uc804\uc5d0: <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><a href=\"http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx#Restrictions\"><span style=\"font-size: 9pt; font-family: Courier New;\">\uc81c\ud55c \uc0ac\ud56d<\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><a href=\"http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx#Security\"><span style=\"font-size: 9pt; font-family: Courier New;\">\ubcf4\uc548<\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"label\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub97c \ub9cc\ub4e4\ub824\uba74 <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><a href=\"http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx#Scalar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\uc2a4\uce7c\ub77c \ud568\uc218 \ub9cc\ub4e4\uae30<\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><a href=\"http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx#TVF\"><span style=\"font-size: 9pt; font-family: Courier New;\">\ud14c\uc774\ube14 \ubc18\ud658 \ud568\uc218 \ub9cc\ub4e4\uae30<\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/li><\/ul><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><a id=\"BeforeYouBegin\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n          \n        <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          \n          <\/span><div class=\"LW_CollapsibleArea_TitleDiv\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><a class=\"LW_CollapsibleArea_TitleAhref\" title=\"\ucd95\uc18c\ud558\ub824\uba74 \ud074\ub9ad\ud558\uc2ed\uc2dc\uc624. \ubaa8\ub450 \ucd95\uc18c\ud558\ub824\uba74 \ub450 \ubc88 \ud074\ub9ad\ud558\uc2ed\uc2dc\uc624.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span class=\"cl_CollapsibleArea_expanding LW_CollapsibleArea_Img\"><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"LW_CollapsibleArea_Title\">\uc2dc\uc791\ud558\uae30 \uc804\uc5d0<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><div class=\"LW_CollapsibleArea_HrDiv\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><hr class=\"LW_CollapsibleArea_Hr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><div class=\"sectionblock\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><a id=\"sectionToggle0\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              \n            <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              \n            <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><a id=\"Restrictions\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              \n            <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><h3 class=\"subHeading\"><span style=\"font-size: 9pt; font-family: Courier New;\">\uc81c\ud55c \uc0ac\ud56d<\/span><\/h3><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"subsection\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><ul><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt6\" class=\"sentence\" data-guid=\"dbff9c51148982d98c4986037468a29e\" data-source=\"User-defined functions cannot be used to perform actions that modify the database state.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc0c1\ud0dc \uc218\uc815 \ub3d9\uc791\uc744 \uc218\ud589\ud558\ub294 \ub370 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt7\" class=\"sentence\" data-guid=\"e7a035c349520b5edd6e1928b7569193\" data-source=\"User-defined functions cannot contain an OUTPUT INTO clause that has a table as its target.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uc5d0\ub294 \ud14c\uc774\ube14\uc774 \ub300\uc0c1\uc778 OUTPUT INTO \uc808\uc744 \ud3ec\ud568\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt8\" class=\"sentence\" data-guid=\"d39c59f1541329dfe7e91c5bf12af6e5\" data-source=\"User-defined functions can not return multiple result sets.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \uc5ec\ub7ec \uacb0\uacfc \uc9d1\ud569\uc744 \ubc18\ud658\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt9\" class=\"sentence\" data-guid=\"13c510d741aff15832a7c1a81c1b643c\" data-source=\"Use a stored procedure if you need to return multiple result sets.\">\uc5ec\ub7ec \uacb0\uacfc \uc9d1\ud569\uc744 \ubc18\ud658\ud574\uc57c \ud558\ub294 \uacbd\uc6b0 \uc800\uc7a5 \ud504\ub85c\uc2dc\uc800\ub97c \uc0ac\uc6a9\ud558\uc2ed\uc2dc\uc624.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt10\" class=\"sentence\" data-guid=\"ea73b338b51e6d45b5dc8c3c815e1f52\" data-source=\"Error handling is restricted in a user-defined function.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc624\ub958 \ucc98\ub9ac\ub294 \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uc5d0\uc11c \uc81c\ud55c\ub429\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt11\" class=\"sentence\" data-guid=\"28f11410ed30044ac9c9b91d451650cd\" data-source=\"A UDF does not support TRY\u2026CATCH, @ERROR or RAISERROR.\">UDF\ub294 TRY\u2026CATCH, @ERROR \ub610\ub294 RAISERROR\ub97c \uc9c0\uc6d0\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt12\" class=\"sentence\" data-guid=\"c6dab1ffc52b19e402472216dd560c16\" data-source=\"User-defined functions cannot call a stored procedure, but can call an extended stored procedure.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \uc800\uc7a5 \ud504\ub85c\uc2dc\uc800\ub97c \ud638\ucd9c\ud560 \uc218 \uc5c6\uc9c0\ub9cc \ud655\uc7a5 \uc800\uc7a5 \ud504\ub85c\uc2dc\uc800\ub294 \ud638\ucd9c\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt13\" class=\"sentence\" data-guid=\"3a77ef9a792a5f808e239bceff08e2b4\" data-source=\"User-defined functions cannot make use of dynamic SQL or temp tables.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \ub3d9\uc801 SQL \ub610\ub294 \uc784\uc2dc \ud14c\uc774\ube14\uc744 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt14\" class=\"sentence\" data-guid=\"fdf71f41e35eb19f572c0d634c1a65ee\" data-source=\"Table variables are allowed.\">\ud14c\uc774\ube14 \ubcc0\uc218\ub294 \ud5c8\uc6a9\ub429\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt15\" class=\"sentence\" data-guid=\"a3f3f5c4557c7a925dddeb9859d41132\" data-source=\"SET statements are not allowed in a user-defined function.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">SET \ubb38\uc740 \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uc5d0\uc11c \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt16\" class=\"sentence\" data-guid=\"403ece834098323d3ac9c566a722cd6a\" data-source=\"The FOR XML clause is not allowed\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">FOR XML \uc808\uc740 \ud5c8\uc6a9\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt17\" class=\"sentence\" data-guid=\"99b7872006da733e48ba11d5a7350823\" data-source=\"User-defined functions can be nested; that is, one user-defined function can call another.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \uc911\ucca9\ub420 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc989, \ud558\ub098\uc758 \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uac00 \ub2e4\ub978 \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub97c \ud638\ucd9c\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt18\" class=\"sentence\" data-guid=\"39f04f3a58636b69f07ee03e7854eb5a\" data-source=\"The nesting level is incremented when the called function starts execution, and decremented when the called function finishes execution.\">\uc911\ucca9 \uc218\uc900\uc740 \ud638\ucd9c\ub41c \ud568\uc218\uc758 \uc2e4\ud589\uc774 \uc2dc\uc791\ub418\uba74 \ub298\uc5b4\ub098\uace0 \ud638\ucd9c\ub41c \ud568\uc218\uc758 \uc2e4\ud589\uc774 \ub05d\ub098\uba74 \uc904\uc5b4\ub4ed\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt19\" class=\"sentence\" data-guid=\"0dfa3533fb323b3c7bc2be867c6cdcad\" data-source=\"User-defined functions can be nested up to 32 levels.\">\uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \ucd5c\ub300 32 \uc218\uc900\uae4c\uc9c0 \uc911\ucca9\ub420 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt20\" class=\"sentence\" data-guid=\"3c0f79472fb361c510d2da4ebb532e29\" data-source=\"Exceeding the maximum levels of nesting causes the whole calling function chain to fail.\">\ucd5c\ub300 \uc911\ucca9 \uc218\uc900\uc744 \ucd08\uacfc\ud558\uba74 \uc804\uccb4 \ud568\uc218 \ud638\ucd9c \uccb4\uc778\uc774 \uc2e4\ud328\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt21\" class=\"sentence\" data-guid=\"928b0249fc08aa07c97061e9a499e394\" data-source=\"Any reference to managed code from a Transact-SQL user-defined function counts as one level against the 32-level nesting limit.\">Transact-SQL \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uc758 \uad00\ub9ac \ucf54\ub4dc \ucc38\uc870\ub294 32 \uc218\uc900\uc758 \uc911\ucca9 \uc81c\ud55c\uc5d0 \ub300\ud574 \ud55c \uc218\uc900\uc73c\ub85c \uacc4\uc0b0\ub429\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt22\" class=\"sentence\" data-guid=\"648f4411ee186b816b6ccb70b8d42f72\" data-source=\"Methods invoked from within managed code do not count against this limit.\">\uad00\ub9ac \ucf54\ub4dc \ub0b4\uc5d0\uc11c \ud638\ucd9c\ub41c \uba54\uc11c\ub4dc\ub294 \uc774 \uc81c\ud55c\uc5d0 \ub530\ub77c \uacc4\uc0b0\ub418\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span id=\"mt23\" class=\"sentence\" data-guid=\"fb51b71955662fa51341bdf4a6438bec\" data-source=\"The following Service Broker statements cannot be included in the definition of a Transact-SQL user-defined function: \"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub2e4\uc74c Service Broker \ubb38\uc740 Transact-SQL \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uc5d0 \ud3ec\ud568\ub420 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><ul><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><span id=\"mt24\" class=\"sentence\" data-guid=\"17a1ebd7d3573e7acc3a6c10d21d6405\" data-source=\"BEGIN DIALOG CONVERSATION\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                          <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">BEGIN DIALOG CONVERSATION<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><span id=\"mt25\" class=\"sentence\" data-guid=\"80e0c1c83ed230c835307f6e9948f36f\" data-source=\"END CONVERSATION\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                          <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">END CONVERSATION<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><span id=\"mt26\" class=\"sentence\" data-guid=\"7f2e70c78057caf7d5b72c459a25928c\" data-source=\"GET CONVERSATION GROUP\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                          <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">GET CONVERSATION GROUP<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><span id=\"mt27\" class=\"sentence\" data-guid=\"d3cb5c1b2d85f727d5584d28e98579be\" data-source=\"MOVE CONVERSATION\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                          <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">MOVE CONVERSATION<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><span id=\"mt28\" class=\"sentence\" data-guid=\"cbd71f0d3114139d38a8d080d610e5fd\" data-source=\"RECEIVE\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                          <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">RECEIVE<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/li><li><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><span id=\"mt29\" class=\"sentence\" data-guid=\"2541d938b0a58946090d7abdde0d3890\" data-source=\"SEND\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                          <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">SEND<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                        <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                      <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><\/li><\/ul><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/li><\/ul><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><a id=\"Security\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              \n            <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><h3 class=\"subHeading\"><span style=\"font-size: 9pt; font-family: Courier New;\">\ubcf4\uc548<\/span><\/h3><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"subsection\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n              <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><a id=\"Permissions\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n              <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><h4 class=\"subHeading\"><span style=\"font-size: 9pt; font-family: Courier New;\">\uc0ac\uc6a9 \uad8c\ud55c<\/span><\/h4><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><div class=\"subsection\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><span id=\"mt30\" class=\"sentence\" data-guid=\"a1b7ff4198b317691193d9f4795bf5f9\" data-source=\"Requires CREATE FUNCTION permission in the database and ALTER permission on the schema in which the function is being created.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub370\uc774\ud130\ubca0\uc774\uc2a4\uc5d0 \ub300\ud55c CREATE FUNCTION \uad8c\ud55c\uacfc \ud568\uc218\uac00 \uc0dd\uc131\ub418\ub294 \uc2a4\ud0a4\ub9c8\uc5d0 \ub300\ud55c ALTER \uad8c\ud55c\uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt31\" class=\"sentence\" data-guid=\"0031340a5960ab3da4b7d345d6929ef3\" data-source=\"If the function specifies a user-defined type, requires EXECUTE permission on the type.\">\ud568\uc218\uc5d0 \uc0ac\uc6a9\uc790 \uc815\uc758 \ud615\uc2dd\uc774 \uc9c0\uc815\ub418\uba74 \ud574\ub2f9 \uc720\ud615\uc5d0 \ub300\ud55c EXECUTE \uad8c\ud55c\uc774 \ud544\uc694\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><img decoding=\"async\" id=\"UpArrow16x16\" alt=\"\ub9e8 \uc704\ub85c \uc774\ub3d9 \ub9c1\ud06c\uc640 \ud568\uaed8 \uc0ac\uc6a9\ub418\ub294 \ud654\uc0b4\ud45c \uc544\uc774\ucf58\" src=\"http:\/\/i.msdn.microsoft.com\/areas\/global\/content\/clear.gif\" title=\"\ub9e8 \uc704\ub85c \uc774\ub3d9 \ub9c1\ud06c\uc640 \ud568\uaed8 \uc0ac\uc6a9\ub418\ub294 \ud654\uc0b4\ud45c \uc544\uc774\ucf58\" class=\"cl_IC169559\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                    <\/span><a href=\"http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx#Intro\"><span style=\"font-size: 9pt; font-family: Courier New;\">[\ub9e8 \uc704\ub85c \uc774\ub3d9]<\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n                  <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><a id=\"Scalar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n          \n        <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><div class=\"LW_CollapsibleArea_TitleDiv\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><a class=\"LW_CollapsibleArea_TitleAhref\" title=\"\ucd95\uc18c\ud558\ub824\uba74 \ud074\ub9ad\ud558\uc2ed\uc2dc\uc624. \ubaa8\ub450 \ucd95\uc18c\ud558\ub824\uba74 \ub450 \ubc88 \ud074\ub9ad\ud558\uc2ed\uc2dc\uc624.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span class=\"cl_CollapsibleArea_expanding LW_CollapsibleArea_Img\"><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"LW_CollapsibleArea_Title\">\uc2a4\uce7c\ub77c \ud568\uc218<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><div class=\"LW_CollapsibleArea_HrDiv\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><hr class=\"LW_CollapsibleArea_Hr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><div class=\"sectionblock\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><a id=\"sectionToggle1\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              \n            <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><span id=\"mt33\" class=\"sentence\" data-guid=\"9bdc87735bc3f971402fc39600f5557e\" data-source=\"The following example creates a multistatement scalar function.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub2e4\uc74c \uc608\uc5d0\uc11c\ub294 \ub2e4\uc911 \ubb38 \uc2a4\uce7c\ub77c \ud568\uc218\ub97c \ub9cc\ub4ed\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span id=\"mt34\" class=\"sentence\" data-guid=\"7a10865c2ff145fa3a047d55c1808777\" data-source=\"The function takes one input value, a <span class=&quot;code&quot;>ProductID<\/span>, and returns a single data value, the aggregated quantity of the specified product in inventory.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\ud568\uc218\uc5d0 <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">ProductID<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uac00 \ub2e8\uc77c \uc785\ub825 \uac12\uc73c\ub85c \uc785\ub825\ub418\uace0 \uc9c0\uc815\ud55c \uc81c\ud488\uc758 \ucd1d \uc7ac\uace0 \uc218\ub7c9\uc774 \ub2e8\uc77c \ub370\uc774\ud130 \uac12\uc73c\ub85c \ubc18\ud658\ub429\ub2c8\ub2e4.<\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><div id=\"code-snippet-1\" class=\"codeSnippetContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerTabs\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetContainerTabSingle\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">Transact-SQL<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerCodeContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetToolBar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"codeSnippetToolBarText\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div id=\"CodeSnippetContainerCode_b55084c8-2f39-4833-9b17-8e7f7d7f93a2\" class=\"codeSnippetContainerCode\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div style=\"color:Black;\"><pre><span style=\"font-size: 9pt; font-family: Courier New;\">USE AdventureWorks2012;\nGO\nIF OBJECT_ID (N'dbo.ufnGetInventoryStock', N'FN') IS NOT NULL\n    DROP FUNCTION ufnGetInventoryStock;\nGO\nCREATE FUNCTION dbo.ufnGetInventoryStock(@ProductID int)\nRETURNS int \nAS \n-- Returns the stock level for the product.\nBEGIN\n    DECLARE @ret int;\n    SELECT @ret = SUM(p.Quantity) \n    FROM Production.ProductInventory p \n    WHERE p.ProductID = @ProductID \n        AND p.LocationID = '6';\n     IF (@ret IS NULL) \n        SET @ret = 0;\n    RETURN @ret;\nEND;\nGO\n<\/span><\/pre><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            \n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><span id=\"mt35\" class=\"sentence\" data-guid=\"426ba4652fcc5d3cbf29247b78017bb0\" data-source=\"The following example uses the <span class=&quot;code&quot;>ufnGetInventoryStock<\/span> function to return the current inventory quantity for products that have a <span class=&quot;code&quot;>ProductModelID<\/span> between 75 and 80.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub2e4\uc74c \uc608\uc5d0\uc11c\ub294 <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">ufnGetInventoryStock<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> \ud568\uc218\ub97c \uc0ac\uc6a9\ud558\uc5ec <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">ProductModelID<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uac00 75\uc640 80 \uc0ac\uc774\uc778 \uc81c\ud488\uc758 \ud604\uc7ac \uc7ac\uace0 \uc218\ub7c9\uc744 \ubc18\ud658\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><div id=\"code-snippet-2\" class=\"codeSnippetContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerTabs\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetContainerTabSingle\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">Transact-SQL<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerCodeContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetToolBar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"codeSnippetToolBarText\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div id=\"CodeSnippetContainerCode_af23a971-27d9-4cff-b361-5d9283f65226\" class=\"codeSnippetContainerCode\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div style=\"color:Black;\"><pre><span style=\"font-size: 9pt; font-family: Courier New;\">USE AdventureWorks2012;\nGO\nSELECT ProductModelID, Name, dbo.ufnGetInventoryStock(ProductID)AS CurrentSupply\nFROM Production.Product\nWHERE ProductModelID BETWEEN 75 and 80;\nGO\n<\/span><\/pre><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            \n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><br \/><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><a id=\"TVF\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n          \n        <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><div class=\"LW_CollapsibleArea_TitleDiv\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><a class=\"LW_CollapsibleArea_TitleAhref\" title=\"\ucd95\uc18c\ud558\ub824\uba74 \ud074\ub9ad\ud558\uc2ed\uc2dc\uc624. \ubaa8\ub450 \ucd95\uc18c\ud558\ub824\uba74 \ub450 \ubc88 \ud074\ub9ad\ud558\uc2ed\uc2dc\uc624.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span class=\"cl_CollapsibleArea_expanding LW_CollapsibleArea_Img\"><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"LW_CollapsibleArea_Title\">\ud14c\uc774\ube14 \ubc18\ud658 \ud568\uc218<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><div class=\"LW_CollapsibleArea_HrDiv\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><hr class=\"LW_CollapsibleArea_Hr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n          <\/span><div class=\"sectionblock\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><a id=\"sectionToggle2\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n              \n            <\/span><\/a><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><span id=\"mt37\" class=\"sentence\" data-guid=\"c37861f6db0aa51fc0e047a7d12d6ff6\" data-source=\"The following example creates an inline table-valued function.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub2e4\uc74c \uc608\uc5d0\uc11c\ub294 \uc778\ub77c\uc778 \ud14c\uc774\ube14 \ubc18\ud658 \ud568\uc218\ub97c \ub9cc\ub4ed\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span id=\"mt38\" class=\"sentence\" data-guid=\"1523b829b952250e6862673f67f1c968\" data-source=\"The function takes one input parameter, a customer (store) ID, and returns the columns <span class=&quot;code&quot;>ProductID<\/span>, <span class=&quot;code&quot;>Name<\/span>, and the aggregate of year-to-date sales as <span class=&quot;code&quot;>YTD Total<\/span> for each product sold to the store.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\ud568\uc218\uc5d0 \uace0\uac1d(\uc0c1\uc810) ID\uac00 \ub2e8\uc77c \uc785\ub825 \ub9e4\uac1c \ubcc0\uc218\ub85c \uc785\ub825\ub418\uace0 <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">ProductID<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">, <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">Name<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> \ubc0f <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">YTD Total<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">(\ud574\ub2f9 \uc0c1\uc810\uc5d0 \ud310\ub9e4\ub41c \uac01 \uc81c\ud488\uc758 \uc5f0\uac04 \ucd1d \ub9e4\ucd9c\uc561) \uc5f4\uc774 \ubc18\ud658\ub429\ub2c8\ub2e4.<\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><div id=\"code-snippet-3\" class=\"codeSnippetContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerTabs\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetContainerTabSingle\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">Transact-SQL<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerCodeContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetToolBar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"codeSnippetToolBarText\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div id=\"CodeSnippetContainerCode_257034ff-7d03-47db-9db8-9612c684a8ae\" class=\"codeSnippetContainerCode\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div style=\"color:Black;\"><pre><span style=\"font-size: 9pt; font-family: Courier New;\">USE AdventureWorks2012;\nGO\nIF OBJECT_ID (N'Sales.ufn_SalesByStore', N'IF') IS NOT NULL\n    DROP FUNCTION Sales.ufn_SalesByStore;\nGO\nCREATE FUNCTION Sales.ufn_SalesByStore (@storeid int)\nRETURNS TABLE\nAS\nRETURN \n(\n    SELECT P.ProductID, P.Name, SUM(SD.LineTotal) AS 'Total'\n    FROM Production.Product AS P \n    JOIN Sales.SalesOrderDetail AS SD ON SD.ProductID = P.ProductID\n    JOIN Sales.SalesOrderHeader AS SH ON SH.SalesOrderID = SD.SalesOrderID\n    JOIN Sales.Customer AS C ON SH.CustomerID = C.CustomerID\n    WHERE C.StoreID = @storeid\n    GROUP BY P.ProductID, P.Name\n);\nGO\n<\/span><\/pre><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            \n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><span id=\"mt39\" class=\"sentence\" data-guid=\"ade9e29abdf9fed2333ae238801e1e68\" data-source=\"The following example invokes the function and specifies customer ID 602.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub2e4\uc74c \uc608\uc5d0\uc11c\ub294 \ud568\uc218\ub97c \ud638\ucd9c\ud558\uace0 \uace0\uac1d ID 602\ub97c \uc9c0\uc815\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><div id=\"code-snippet-4\" class=\"codeSnippetContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerTabs\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetContainerTabSingle\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">Transact-SQL<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerCodeContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetToolBar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"codeSnippetToolBarText\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div id=\"CodeSnippetContainerCode_7d1e9f87-aabf-4299-a158-3157e8af4df2\" class=\"codeSnippetContainerCode\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div style=\"color:Black;\"><pre><span style=\"font-size: 9pt; font-family: Courier New;\">SELECT * FROM Sales.ufn_SalesByStore (602);\n<\/span><\/pre><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            \n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><p><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><span id=\"mt40\" class=\"sentence\" data-guid=\"e164909cef091b97166b5f41ddc555c4\" data-source=\"The following example creates a table-valued function.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                <\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\ub2e4\uc74c \uc608\uc5d0\uc11c\ub294 \ud14c\uc774\ube14 \ubc18\ud658 \ud568\uc218\ub97c \ub9cc\ub4ed\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\n              <\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span id=\"mt41\" class=\"sentence\" data-guid=\"06b77b83af6f7e4ffa2afae1ad02fa66\" data-source=\"The function takes a single input parameter, an <span class=&quot;code&quot;>EmployeeID<\/span> and returns a list of all the employees who report to the specified employee directly or indirectly.\"><span style=\"font-size: 9pt; font-family: Courier New;\">\ud568\uc218\uc5d0 <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" class=\"code\">EmployeeID<\/span><span style=\"font-size: 9pt; font-family: Courier New;\">\uac00 \ub2e8\uc77c \uc785\ub825 \ub9e4\uac1c \ubcc0\uc218\ub85c \uc785\ub825\ub418\uace0 \uc9c0\uc815\ud55c \uc9c1\uc6d0\uc5d0\uac8c \uc9c1\uc811 \ub610\ub294 \uac04\uc811\uc801\uc73c\ub85c \ubcf4\uace0\ud558\ub294 \ubaa8\ub4e0 \uc9c1\uc6d0\uc758 \ubaa9\ub85d\uc774 \ubc18\ud658\ub429\ub2c8\ub2e4.<\/span><\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><span style=\"font-size: 9pt; font-family: Courier New;\" id=\"mt42\" class=\"sentence\" data-guid=\"9084ba8fc0f3189d453a7707fa9056d4\" data-source=\"The function is then invoked specifying employee ID 109.\">\uadf8\ub7f0 \ub2e4\uc74c \uc9c1\uc6d0 ID 109\ub97c \uc9c0\uc815\ud558\uc5ec \ud568\uc218\ub97c \ud638\ucd9c\ud569\ub2c8\ub2e4.<\/span><span style=\"font-size: 9pt; font-family: Courier New;\"> <\/span><\/p><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div><span style=\"font-size: 9pt; font-family: Courier New;\">\n<\/span><div id=\"code-snippet-5\" class=\"codeSnippetContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerTabs\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetContainerTabSingle\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">Transact-SQL<\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n    <\/span><div class=\"codeSnippetContainerCodeContainer\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div class=\"codeSnippetToolBar\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div class=\"codeSnippetToolBarText\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n                \n            <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><\/div><span style=\"font-size: 9pt; font-family: Courier New;\">\n        <\/span><div id=\"CodeSnippetContainerCode_ff32ee55-bf73-4979-9865-589ce03ea6ce\" class=\"codeSnippetContainerCode\" dir=\"ltr\"><span style=\"font-size: 9pt; font-family: Courier New;\">\n            <\/span><div style=\"color:Black;\"><pre><span style=\"font-size: 9pt; font-family: Courier New;\">USE AdventureWorks2012;\nGO\nIF OBJECT_ID (N'dbo.ufn_FindReports', N'TF') IS NOT NULL\n    DROP FUNCTION dbo.ufn_FindReports;\nGO\nCREATE FUNCTION dbo.ufn_FindReports (@InEmpID INTEGER)\nRETURNS @retFindReports TABLE \n(\n    EmployeeID int primary key NOT NULL,\n    FirstName nvarchar(255) NOT NULL,\n    LastName nvarchar(255) NOT NULL,\n    JobTitle nvarchar(50) NOT NULL,\n    RecursionLevel int NOT NULL\n)\n--Returns a result set that lists all the employees who report to the \n--specific employee directly or indirectly.*\/\nAS\nBEGIN\nWITH EMP_cte(EmployeeID, OrganizationNode, FirstName, LastName, JobTitle, RecursionLevel) -- CTE name and columns\n    AS (\n        SELECT e.BusinessEntityID, e.OrganizationNode, p.FirstName, p.LastName, e.JobTitle, 0 -- Get the initial list of Employees for Manager n\n        FROM HumanResources.Employee e \n                        INNER JOIN Person.Person p \n                   ON p.BusinessEntityID = e.BusinessEntityID\n        WHERE e.BusinessEntityID = @InEmpID\n        UNION ALL\n        SELECT e.BusinessEntityID, e.OrganizationNode, p.FirstName, p.LastName, e.JobTitle, RecursionLevel + 1 -- Join recursive member to anchor\n        FROM HumanResources.Employee e \n            INNER JOIN EMP_cte\n            ON e.OrganizationNode.GetAncestor(1) = EMP_cte.OrganizationNode\n                   INNER JOIN Person.Person p \n                   ON p.BusinessEntityID = e.BusinessEntityID\n        )\n-- copy the required columns to the result of the function \n   INSERT @retFindReports\n   SELECT EmployeeID, FirstName, LastName, JobTitle, RecursionLevel\n   FROM EMP_cte \n   RETURN\nEND;\nGO\n-- Example invocation\nSELECT EmployeeID, FirstName, LastName, JobTitle, RecursionLevel\nFROM dbo.ufn_FindReports(1); \n\nGO<\/span><img decoding=\"async\" id=\"UpArrow16x16\" alt=\"\ub9e8 \uc704\ub85c \uc774\ub3d9 \ub9c1\ud06c\uc640 \ud568\uaed8 \uc0ac\uc6a9\ub418\ub294 \ud654\uc0b4\ud45c \uc544\uc774\ucf58\" src=\"http:\/\/i.msdn.microsoft.com\/areas\/global\/content\/clear.gif\" title=\"\ub9e8 \uc704\ub85c \uc774\ub3d9 \ub9c1\ud06c\uc640 \ud568\uaed8 \uc0ac\uc6a9\ub418\ub294 \ud654\uc0b4\ud45c \uc544\uc774\ucf58\" class=\"cl_IC169559\"><span style=\"font-size: 9pt; font-family: Gulim,\uad74\ub9bc,AppleGothic,sans-serif;\"><\/span><\/pre><\/div><\/div><\/div><\/div><\/div><\/div><\/div><p><br \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc6d0\ubb38 : http:\/\/msdn.microsoft.com\/ko-kr\/library\/ms191320%28v=sql.110%29.aspx \uc774 \ud56d\ubaa9\uc5d0\uc11c\ub294 Transact-SQL\uc744 \uc0ac\uc6a9\ud558\uc5ec SQL Server 2012\uc5d0\uc11c Transact-SQL \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub97c \ub9cc\ub4dc\ub294 \ubc29\ubc95\uc5d0 \ub300\ud574 \uc124\uba85\ud569\ub2c8\ub2e4. \ud56d\ubaa9 \ub0b4\uc6a9 \uc2dc\uc791\ud558\uae30 \uc804\uc5d0: \uc81c\ud55c \uc0ac\ud56d \ubcf4\uc548 \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub97c \ub9cc\ub4e4\ub824\uba74 \uc2a4\uce7c\ub77c \ud568\uc218 \ub9cc\ub4e4\uae30 \ud14c\uc774\ube14 \ubc18\ud658 \ud568\uc218 \ub9cc\ub4e4\uae30 \uc2dc\uc791\ud558\uae30 \uc804\uc5d0 \uc81c\ud55c \uc0ac\ud56d \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\ub294 \ub370\uc774\ud130\ubca0\uc774\uc2a4 \uc0c1\ud0dc \uc218\uc815 \ub3d9\uc791\uc744 \uc218\ud589\ud558\ub294 \ub370 \uc0ac\uc6a9\ud560 \uc218 \uc5c6\uc2b5\ub2c8\ub2e4. \uc0ac\uc6a9\uc790 \uc815\uc758 \ud568\uc218\uc5d0\ub294 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[10],"tags":[],"class_list":["post-450","post","type-post","status-publish","format-standard","hentry","category-computing_database"],"_links":{"self":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/450","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=450"}],"version-history":[{"count":0,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=\/wp\/v2\/posts\/450\/revisions"}],"wp:attachment":[{"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=450"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=450"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hasu0707.duckdns.org\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=450"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}