![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, My code is running a bit slow. I'm using a cursor to perform updates based on an ID. Any thoughts on ways of optimising? |
#3
| |||||||
| |||||||
|
|
Hi, My code is running a bit slow. |
|
I'm using a cursor to perform updates based on an ID. Any thoughts on ways of optimising? |
|
Your thoughts/ideas will be greatly appreciated. DECLARE Data_Category_Cursor CURSOR FOR SELECT Client_Site_ID, Site_Data_Category, Client_Site_Data_Category_Value FROM USys_View_Sorted_Client_Site_Data_Category_Hosting ORDER BY Client_Site_ID |
| DECLARE @Site_ID NVARCHAR(50) DECLARE @Data_Category_Value VARCHAR(50) DECLARE @Data_Category VARCHAR(50) OPEN Data_Category_Cursor FETCH NEXT FROM Data_Category_Cursor INTO @Site_ID, @Site_Data_Category, @Data_Category_Value |
|
WHILE @@FETCH_STATUS = 0 BEGIN SET @SQL = N'UPDATE USys_tbl_Temp_Site_Output_SQL SET ' + @Site_Data_Category + ' = ''' + @Data_Category_Value + '''' + ' WHERE Client_Site_ID = ''' + @Site_ID + '''' +';' |
|
EXEC @ErrorCode = sp_executesql @SQL FETCH NEXT FROM Data_Category_Cursor INTO @Site_ID, @Site_Data_Category, @Data_Category_Value END Close Data_Category_Cursor DEALLOCATE Data_Category_Cursor [deleted more of the same kind of code] |
|
Many Thanks Flick |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |