使用Union时如何声明 [英] How to declare when using Union
本文介绍了使用Union时如何声明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我要Union
的语句:
this are the statements that i want to Union
:
Create PROCEDURE[dbo].[spUnion3]
(
@RigionID int)
AS SELECT Schools.SchoolName
FROM SchoolDistrict, Schools
WHERE SchoolDistrict.SchoolDistrictID = Schools.DistrictID AND SchoolDistrict.RegionID = @RegionID
UNION
SELECT ECD.ECDName
FROM SchoolDistrict, ECD
WHERE SchoolDistrict.SchoolDistrictID = ECD.DistrictID AND SchoolDistrict.RegionID = @RegionID
但这给了我这个错误信息:
But it gives me this error massage:
"Must declare the scalar variable "@RegionID".".
请帮助.
尝试作为storedprosedure这样做,它给了我同样的错误,但是在第二个区域中,参数
Please help.
tried to doing it as storedprosedure it gives me the same error but on the 2nd Region Parameter
推荐答案
视图不支持参数:W3Schools [ ^ ]-而是将其创建为存储过程.
VIEWs do not support parameters: W3Schools[^] - create it as a stored procedure instead.
参数为@RigionID
,并且您已使用@RegionID
您的代码中只有一个错字;)
The parameter is@RigionID
and you have used@RegionID
There is only a typo in your code ;)
这篇关于使用Union时如何声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文