我正在使用powershell和bcp将数千个文件加载到表中。对于每个数据文件,我都会为要填充的列创建默认值。然后,我删除该默认值,并为下一个文件添加一个新值,以此类推。
代码在这里:
let isDragging = false;
let $target = null;
let mouseY = 0;
let pMouseY = 0;
const handleHeight = 12;
const $layout = $('.layout'),
$panels = $('.panel'),
$handles = $('.v-handle');
$panels.on('resize-panel', function() {
let canResize = true;
$this = $(this);
$prev = $(this).prev();
$next = $(this).next();
if(mouseY - pMouseY > 0) {
// we're draggin down
if($this.height() - (mouseY - pMouseY) < handleHeight) {
console.log('check below');
canResize = ($next.length != 0 && $next.trigger('resize-panel'));
}
} else {
// we're dragging up
if($prev.height() + (mouseY - pMouseY) < handleHeight) {
console.log('check above');
canResize = ($prev.trigger('resize-panel'));
}
}
if(canResize) {
$this.css('height', $this.height() - (mouseY - pMouseY));
$prev.css('height', $prev.height() + (mouseY - pMouseY));
}
return canResize;
});
$handles.on('mousedown', function(e) {
isDragging = true;
$target = $(this);
mouseY = pMouseY = e.clientY;
console.log('mousedown');
});
$layout.on('mousemove', function(e) {
if(isDragging) {
mouseY = e.clientY;
$target.parent().trigger('resize-panel');
pMouseY = e.clientY;
}
})
.on('mouseup', function() {
isDragging = false;
});
我已经从bcp命令中删除了标识信息。该代码在循环中运行数千次,每个数据文件一次。在某个时候,我收到以下超时错误。
$query = "alter table $tableName add constraint DF_temp_jobID_$tableName default $dir_id for jobID"
$sqlCmd2 = $connection.CreateCommand()
$sqlCmd2.Connection = $connection
$sqlCmd2.CommandText = $query
$sqlCmd2.ExecuteReader()
bcp "$tableName" in "$dir_id${string}.csv" -f "formatFile_file.fmt" -U
$query = "alter table $tableName drop constraint DF_temp_jobID_$tableName"
$sqlCmd3 = $connection.CreateCommand()
$sqlCmd3.Connection = $connection
$sqlCmd3.CommandText = $query
$sqlCmd3.ExecuteReader()
此错误发生得相当快。默认超时为600秒左右。我没有等那么久。我不明白为什么您在删除或添加约束时会超时。感觉应该是一个恒定时间的操作,或者接近它。