SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= CREATE FUNCTION csj_csj(@id as int) RETURNS @temp table --這裡返回一個自己創建的表,裡面的字段根據自己的需要設 ( [id] int, [zd] varchar(100), [xl] varchar(100) ) AS BEGIN insert into @temp select id,zd,xl from deb -- 把查詢出的Sql語句插入到臨時表中,注意字段一致 return --這裡別忘了return,不然不給查詢! END GO