SQLserver视图中定义参数
1 CREATE TABLE TestTable 2 ( 3 ID INT,Name NVARCHAR(20), 4 International nvarchar(200) 5 ) 6 7 INSERT INTO TestTable 8 SELECT '1','JACK','CHINA' UNION ALL 9 SELECT '2','TOM','CHINA' UNION ALL 10 SELECT '3','JOHN','JAPAN' UNION ALL 11 SELECT '4','ALICE','FRANCH' UNION ALL 12 SELECT '5','DORIS','AMERICA' UNION ALL 13 SELECT '6','TRRRY','CHINA' 14 GO 15 16 create VIEW V_INFO 17 AS 18 SELECT * FROM TestTable WHERE International='CHINA' 19 GO 20 21 --1-- 22 CREATE FUNCTION FN_INFO(@INPUT_PARAMETER NVARCHAR(30)) 23 RETURNS TABLE 24 AS 25 RETURN 26 (SELECT * FROM V_INFO WHERE International=@INPUT_PARAMETER) 27 GO 28 29 select * from FN_INFO(N'AMERICA') 30 GO 31 32 --2-- 33 CREATE FUNCTION FN_INFO_ID(@ID_PARAMETER NVARCHAR(30)) 34 RETURNS TABLE 35 AS 36 RETURN 37 (SELECT * FROM V_INFO WHERE ID=@ID_PARAMETER) 38 GO 39 40 select * from FN_INFO_ID(6)