首页 > 数据库技术 > 详细

SQLserver视图中定义参数

时间:2020-04-15 10:49:29      阅读:483      评论:0      收藏:0      [点我收藏+]
 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(NAMERICA)
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)

 

SQLserver视图中定义参数

原文:https://www.cnblogs.com/lgx5/p/12703197.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!