我有家政存储程序。 我执行查询管理时遇到问题。完成35000行的脚本需要更长的时间。 是因为sql server性能?因为当我在localhost中运行时,内存使用较少,它可以顺利执行并完成大约1小时。 我正在使用删除。以下是我的看家脚本示例。 - 构建SQL语句 - 开始
SET @SQLStatement = 'DELETE FROM dbo.tPgt_ReviewedFile WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_WorkFlow WHERE [File_Id] = ' + LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.mHost_Inquiries WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement + '; DELETE FROM dbo.' + @TableName
+ ' WHERE [File_Id] = ' + LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_FileRemarks WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_FileProducts WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tFile_FeeCalculated WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_SubFeeDetails WHERE Sub_File_Id = '
+ LTRIM(STR(@SubFileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_ReceivingFeeDetails WHERE Sub_File_Id = '
+ LTRIM(STR(@SubFileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_SubFileDetails WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tFile_CustomerHeader WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
SET @SQLStatement = @SQLStatement
+ '; DELETE FROM dbo.tPgt_FileDetails WHERE [File_Id] = '
+ LTRIM(STR(@FileId))
- 构建SQL语句 - 停止