SQL Server 2008 ã®ã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åã¨ãã¼ãã«å¤ãã©ã¡ã¼ã¿ ãã®1
SQL Server 2008 ããã¯ããã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åãã¨ããã¼ãã«å¤ãã©ã¡ã¼ã¿ãããµãã¼ãããã¾ããã
ã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åï¼User-Defined Table Typeï¼ã¯ãã¦ã¼ã¶ã¼å®ç¾©ã® Table ãã¼ã¿åã«å¯¾ãã¦ãååãä»ãã¦åï¼Typeï¼ã¨ãã¦ä¿åã§ããæ©è½ã§ãã
ãã¼ãã«å¤ãã©ã¡ã¼ã¿ï¼Table-Valued Parametersï¼ã¯ãã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åããã©ã¡ã¼ã¿ï¼ã¹ãã¢ã ããã·ã¼ã¸ã£ãªã©ã®å¼æ°ï¼ã¨ãã¦æå®ã§ããæ©è½ã§ãã
ããã¯æ¬¡ã®ããã«è©¦ããã¨ãã§ãã¾ãã
-- ã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åã®ä½æ CREATE TYPE testTableType AS TABLE ( a int, b varchar(100) ) go -- ãã¼ãã«å¤ãã©ã¡ã¼ã¿ãå©ç¨ããã¹ãã¢ã ããã·ã¼ã¸ã£ã®ä½æ CREATE PROCEDURE testProc1 @tvp testTableType READONLY AS INSERT INTO t1 SELECT * FROM @tvp
ä½æããã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åã¸å¤ãä»£å ¥ãããããã¹ãã¢ã ããã·ã¼ã¸ã£ã¸æ¸¡ãã¦å®è¡ããã«ã¯ã次ã®ããã«è¨è¿°ãã¾ãã
-- ã¦ã¼ã¶ã¼å®ç¾©ãã¼ãã«åãå©ç¨ããå¤æ° @tvp1 ã®å®£è¨ DECLARE @tvp1 AS testTableType -- å¤æ° @tvp1 ã¸å¤ã®æ ¼ç´ INSERT INTO @tvp1 (a, b) VALUES ( 7, 'AAAAAA') ,( 8, 'BBBBBB') -- ã¹ãã¢ã ããã·ã¼ã¸ã£ã®å®è¡ EXEC testProc1 @tvp1 -- çµæã®ç¢ºèª SELECT * FROM t1
ãã®ã»ãã® SQL Server 2008 ã®æ°æ©è½ã®å
·ä½çãªå©ç¨æ¹æ³ã«ã¤ãã¦ã¯ãå¼ç¤¾å·çã® SQL Server 2008 èªç¿æ¸ã·ãªã¼ãºï¼ä¸è¨ URLï¼ã®ãSQL Server 2008 ã®æ³¨ç®ã®æ°æ©è½ãã¤ãæ©ã試ãã¦ã¿ãã! ãç·¨ãåèã«ãã¦ã¿ã¦ãã ããã
http://www.microsoft.com/japan/sqlserver/2008/self-learning/default.mspx