Update Statement :: You Need to Copy for uses.... Click Read More
declare @CtnInfo cursor
set @CtnInfo= CURSOR FOR
select fldRowID, RevisedNo , Sub1.Head_ID
from OPENDATASOURCE ('SQLOLEDB', 'Data Source=192.168.1.251;User ID=sa;Password=dblgroup' ).DBL_Group.dbo.tbl_OrderDetails_Temp O
INNER JOIN (
select Head_ID, MAX( RevisedNo) MaxRevisedNo
from OPENDATASOURCE ('SQLOLEDB', 'Data Source=192.168.1.251;User ID=sa;Password=dblgroup' ).DBL_Group.dbo.tbl_OrderDetails_Temp O
group by Head_ID
) Sub1 on O.Head_ID = Sub1.Head_ID And O.RevisedNo = Sub1.MaxRevisedNo
WHERE fldRowID BETWEEN 1437540 AND 1521264
order by Head_ID
declare @tblBody nvarchar(max)
set @tblBody= 'Start : '
OPEN @CtnInfo
FETCH NEXT
FROM @CtnInfo INTO
@JALID , @reviseno , @JALHead_ID
WHILE @@FETCH_STATUS = 0
BEGIN
Select 'Beefore update : ' + CONVERT(nvarchar(20), @JALID ) + '---' + CONVERT(nvarchar(20), @reviseno ) + '---' + CONVERT(nvarchar(20), @JALHead_ID )
select * from dbo.tblOrderBookingDetailBody WHERE BookingDetailsID_JAL = @JALID
UPDATE dbo.tblOrderBookingDetailBody set HeadID_JAL= @JALHead_ID WHERE BookingDetailsID_JAL = @JALID
Select 'After update : '
select * from dbo.tblOrderBookingDetailBody WHERE BookingDetailsID_JAL = @JALID
SET @tblBody=@tblBody+ ', @JALID : ' + CONVERT(nvarchar(40), @JALID ) +', @reviseno : '+ CONVERT(nvarchar(40), @reviseno )
FETCH NEXT
FROM @CtnInfo INTO
@JALID , @reviseno , @JALHead_ID --fldRowID, RevisedNo , Sub1.Head_ID
END
CLOSE @CtnInfo
DEALLOCATE @CtnInfo
select @tblBody as TotalSelecteddata
No comments:
Post a Comment
I am Safiqul Islam Tuhin