1
我已經嘗試過使用內部連接來實現一個存儲過程來顯示不同表中的結果,但是我的問題是select語句沒有返回任何結果,但它將一些值打印爲消息。存儲過程中的「選擇」語句不起作用
alter proc EmployeeReport(@empid int)
as
begin
declare @inTime time(0)
declare @outTime time(0)
declare @fromDate date
declare @toDate date
set @inTime = (select CAST(InTime as time(0)) from Timelog where [email protected])
set @outTime = (select CAST(OutTime as time(0)) from Timelog where EmployeeId = @empid)
set @fromDate = (select cast (InTime as date) from Timelog where EmployeeId= @empid)
set @toDate = (select cast (outTime as date) from Timelog where EmployeeId= @empid)
select @fromDate as FromDate
,@toDate as ToDate
,c.Name as Client
,p.Name as Project
,@inTime as InTime
,@outTime as OutTime
,t.TotalTime
from Timelog t
inner join Employee e
on e.id = t.EmployeeId
inner join Project p
on p.Id = t.EmployeeProjectId
inner join Client c
on c.Id = p.ClientId
where t.EmployeeId = @empid
print @inTime
print @outTime
print @fromDate
print @toDate
end
我附上輸出文件什麼我收到,請幫助我這個
內留言得到印刷:
沒有返回的值或選擇:
檢查您的加入,請。另外,您的select語句中缺少where子句 –
我嘗試使用where子句,但仍然無法正常工作 –
您不需要所有這些變量,只需在查詢中選擇這些變量即可。如果你想保留變量,你應該在一個select語句中而不是4中執行它。 –