您好我正在使用联接表查询来检索一些数据..
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 =@EmployeeID
END
--Select * From HRLeaveMasterTemp
如果leavebalance为空,我需要表格显示0..但语句显示错误..请帮助我..