DECLARE @_RelationRowId_SourceDocXML NVARCHAR(MAX)
SET @_RelationRowId_SourceDocXML = (
	SELECT i.BizDocId AS RowId_SourceDoc, i.DocCode, i.DocDate, i.DocNo, i.DocStatus, i.IsActive
		FROM dbo.B30BizDoc i
		WHERE i.DocCode = 'RC'
		FOR XML RAW, ROOT('root'))
 
EXECUTE [dbo].[usp_B30DocRelation_Update]
	@_BranchCode = 'A01',
	@_nUserId = -1,
	@_RelationRowId_SourceDocXML = @_RelationRowId_SourceDocXML,
	@_LangId = 0
GO
 
DECLARE @_RelationRowId_SourceDocXML NVARCHAR(MAX)
SET @_RelationRowId_SourceDocXML = (
	SELECT i.Stt AS RowId_SourceDoc, i.DocCode, i.DocDate, i.DocNo, i.DocStatus, i.IsActive
		FROM dbo.B30AccDocPurchase i
		WHERE i.BranchCode = 'A01' AND i.DocCode = 'NM'
		FOR XML RAW, ROOT('root'))
		
EXECUTE [dbo].[usp_B30DocRelation_Update]
	@_BranchCode = 'A01',
	@_nUserId = -1,
	@_RelationRowId_SourceDocXML = @_RelationRowId_SourceDocXML,
	@_LangId = 0
GO