【发布时间】:2014-10-24 20:53:34
【问题描述】:
我正在使用 AdventureWorks 2012 数据库,我完全被这个数据库难住了,
目前为止
alter proc pName
(
@TranID int
)
as
declare @AccountID int
declare @Entered datetime
declare @Type char
declare @Amount money
declare @Service money
declare @WithdrawalDecrease smallint
declare @WithdrawalCount smallint
set @AccountID = (select AccountID
from Transactions
where TransID = @TranID)
set @WithdrawalCount = (select WithdrawalCount
from Accounts
inner join Transactions on Transactions.AccountID = Accounts.AccountID
where Transactions.AccountID = @AccountID)
但是变量取值我做错了什么?
【问题讨论】:
-
有什么问题?你有错误吗?你收到的价值不是你所期望的吗?我们需要一些工作。
-
变量不会取值没有错误只是空值
-
这条语句“select AccountID from TransID = @TranID”返回了多少
-
我得到 1,值为 7 in,AccountID = 2
-
你能再清楚一点我没有得到最后的评论
标签: sql join sql-server-2012