你好我使用的是加入表查詢來獲取一些數據..SQL語句連接表是空查詢
USE [AccountingSystem_TEST]
GO
/****** Object: StoredProcedure [dbo].[spHRLeaveEntitlementBuildTemp] Script Date: 03/14/2013 09:18:06 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER Procedure [dbo].[spHRLeaveEntitlementBuildTemp]
(
@CreatedUserID as nvarchar(9)
,@EmployeeID nvarchar(9)
,@EmpName nvarchar(150)
)
AS
BEGIN
Select A.CodeHRLeaveType,
COALESCE(B.LeaveBalance) LeaveBalance
From HRLeaveType A
LEFT JOIN HRLeaveMaster B
On A.CodeHRLeaveType = B.CodeHRLeaveType
Where B.EmployeeID = @EmployeeID
Delete dbo.HrLeaveMasterTemp
Where UserID = @CreatedUserID
INSERT INTO [dbo].[HrLeaveMasterTemp]
([UserID]
,[EmployeeID]
,[EmpName]
,[CodeHRLeaveType]
,[LeaveBalance]
,[Status]
)
Select
@CreatedUserID
,[EmployeeID]
,@EmpName
,[CodeHRLeaveType]
,[LeaveBalance]
,[Status]
From dbo.[HRLeaveMaster]
Where EmployeeID [email protected]
END
--Select * From HRLeaveMasterTemp
如果leavebalance爲null,我需要的表格顯示0 ..但聲明顯示錯誤。請幫助我..
嘗試編輯答案,是否有利於你... – 2013-03-14 03:36:40