私は列を出力するストアドプロシージャを持っています。それは問題なく動く。SQLクエリのヘルプ:エラーは、ストアドプロシージャからのテンポラリテーブルへの挿入
exec dbo.sp_SelectAlignmentSubset
@AlnID
,@ParentTaxID
,@SeqTypeID
,@LocationID
,@SubsetSize
,@SimilarityThreshold
,@SimilarityTable
,@AnchorSeqID
しかし、私は一時テーブルにプロシージャの出力を挿入すると、
create table #resultSeqIDs
(
SeqID int not null
)
Insert into #resultSeqIDs
exec dbo.sp_SelectAlignmentSubset
@AlnID
,@ParentTaxID
,@SeqTypeID
,@LocationID
,@SubsetSize
,@SimilarityThreshold
,@SimilarityTable
,@AnchorSeqID
エラーが事前に"The current transaction cannot be committed and cannot support operations that write to the log file. Roll back the transaction."
感謝を飛び出します。
手順のクエリはここにある:
Alter Proc dbo.sp_SelectAlignmentSubset
@AlnID int,
@ParentTaxID int,
@SeqTypeID int,
@LocationID int,
@SubsetSize int,
@SimilarityThreshold float,
@SimilarityTable nvarchar(255),
@AnchorSeqID int = null
As
declare @sql nvarchar(4000), @param nvarchar(2000), @subsetActualSize int, @lastSeqID int, @meanSimilarity float
--- Cleaning
begin try
drop table #Subset
end try
begin catch
end catch
begin try
drop table #tmpAllSeqs
end try
begin catch
end catch
begin try
drop table #AllSeqs
end try
begin catch
end catch
--- Create temp tables
create table #Subset
(
SeqID int not null
)
create table #AllSeqs
(
SeqID int not null
)
create table #tmpAllSeqs
(
SeqID int not null,
Similarity float not null
)
--- Prepare anchor
if @AnchorSeqID is not null
begin
Insert into #Subset values (@AnchorSeqID)
set @lastSeqID = @AnchorSeqID
end
--- Get all SeqIDs in the alignment under the parent taxID
Insert into #AllSeqs
Select SeqID
from dbo.fn_SelectAlignedSequences(@AlnID, @ParentTaxID, @SeqTypeID, @LocationID)
--- Put SeqIDs into #Subset
select @subsetActualSize = count(*) from #Subset
while @subsetActualSize < @SubsetSize
begin
-- select 'Subset size:'+cast(@subsetActualSize as nvarchar(10))
truncate table #tmpAllSeqs
set @sql =
' Insert into #tmpAllSeqs
select st.SeqID2 as SeqID
,st.Similarity
from ' + @SimilarityTable + ' st
where st.SeqID1 = @lastSeqID
and st.SeqID2 in (select SeqID from #AllSeqs)
and st.Similarity <= @SimilarityThreshold
'
set @param = '@lastSeqID int, @SimilarityThreshold float'
exec sp_executesql @sql, @param, @lastSeqID, @SimilarityThreshold
--- Mark the SeqID will be selected from #AllSeqs and
--- added to #Subset in this round
---
--- Here I select the SeqID with minimum difference from
--- mean of similarity as the SeqID
select @meanSimilarity = AVG(Similarity)
from #tmpAllSeqs
select top 1 @lastSeqID = SeqID
from #tmpAllSeqs
order by abs(Similarity - @meanSimilarity) asc
Insert into #Subset values (@lastSeqID)
--- Update #AllSeqs (all candidate SeqIDs)
truncate table #AllSeqs
Insert into #AllSeqs
select SeqID
from #tmpAllSeqs
--- Increment size of #Subset
select @subsetActualSize = count(*) from #Subset
end
select SeqID from #Subset
drop table #Subset
drop table #AllSeqs
drop table #tmpAllSeqs
Go
[トランザクションログで問題が発生しているSQLジョブ...]の複製が可能です。(http://stackoverflow.com/questions/1039391/sql-job-having-issues-with-transaction-log) – JNK
これは便利です。私はあなたのリンクをたどって、私がそれらを取り除くと、 "try try ... end try ... begin catch ... end catch"を見つけたら、それはうまくいきます。 – Mavershang
more ...(re:XACT_STATEのチェックとログへの書き込み)http://www.codeproject.com/KB/database/try_catch.aspx – Chains