我的代码有问题吗?我得到一个例外:
执行超时已过期。操作完成之前经过的超时时间或服务器没有响应。
我正在尝试使用动态列更新动态表,具体取决于用户的搜索工具
ALTER PROCEDURE SP_UPDATE_FACILITY
@featid int,
@facilityid int,
@updatetbl as TABLE_UPDATE_FACILITYDETAILS READONLY
AS
BEGIN
SET NOCOUNT ON;
DECLARE @tblname AS NVARCHAR(255);
SET @tblname = (SELECT dbo.FNC_Search_GetSearchTable(@facilityid));
DECLARE @key varchar(255);
DECLARE @value varchar(255);
DECLARE @MyCursor CURSOR
SET @MyCursor = CURSOR FOR
SELECT col_key, col_value FROM @updatetbl
OPEN @MyCursor
FETCH NEXT FROM @MyCursor INTO @key , @value
WHILE @@FETCH_STATUS = 0
BEGIN
IF(@key != '' and @value != '')
BEGIN
BEGIN TRY
SET @value = (CAST ( @value AS varchar(255)));
END TRY
BEGIN CATCH
SET @value = (CAST ( @value AS float));
END CATCH;
DECLARE @sSQL NVARCHAR(500);
SET @sSQL = 'UPDATE ' + QUOTENAME(@tblname) + ' SET ' + QUOTENAME(@key) + ' = @value WHERE FEATID = @featid'
EXEC sp_executesql @sSQL , N'@value VARCHAR(255), @featid INT', @key, @featid
FETCH NEXT FROM @MyCursor INTO @key, @value
END
END;
CLOSE @MyCursor ;
DEALLOCATE @MyCursor;
END
GO
有没有办法循环遍历表格,然后获取每行表格的值
答案 0 :(得分:2)
SQL Server没有任何“执行超时”,而客户端可以设置它。
如果使用C#,则默认执行超时为30秒,太小。
当然,您应该使用sys.dm_os_waiting_tasks
调查您的查询正在等待的内容,但如果30秒不足以完成您的代码,只需将此执行超时值更改为smth else(0 =无限)