0
我有一個問題,與我的一個交易。我把它打印多少行已經觸及@RowCount使用:@rowcount問題與交易
create proc Proc_Whole_Months_Work
@ProjectNum int,
@EmpId int,
@StartDate datetime,
@EndDate datetime
as
BEGIN TRANSACTION
declare @CurrentDate datetime
DECLARE @rowcount int
set @CurrentDate = @StartDate
while (@CurrentDate <= @EndDate)
begin
if (datepart(WEEKDAY, @CurrentDate) <=5)--if it is a weekday
begin
insert into WorkHours(ProjectNum,EmpId,WorkDate,BeginTime,EndTime)values (@ProjectNum,@EmpId,@CurrentDate,'09:00:00','17:00:00')
end
set @CurrentDate =DATEADD(dd, 1, @CurrentDate)
end
SET @rowcount = @@ROWCOUNT
--print @rowcount
if(@rowcount = 0)
PRINT 'No rows Updated'
else
print 'Number Of Rows Updated:' + ' ' + str(@rowcount)
COMMIT TRANSACTION
去
出於某種原因,我似乎不明白,程序打印「沒有行更新」,即使有行更新! 任何想法我做錯了什麼? 非常感謝!
非常感謝您的回答!但它仍然沒有行更新..:\(1行受影響) (1 row(s)affected) 沒有行更新 – user2693861
1.嘗試在您的過程中打印@rowcount。 2.你確定有插入的行嗎? –