|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Stored procedure is taking lot of time to execute
I tried to execute this stored procedure. This procedure is taking lot of time.
I don't know wether it is going in infinite loop or what's happening. I has inserted 51168 records in tblProducts_Categories table. Total I want to insert 51170. Two records are missing. Can anyone help why this stored procedure is taking long time to execute In this stored procedure what I am trying to do is I have 3 tables 1)tblCategory with categoryID, categoryName column names 2)tblProducts with productID, productName column names 3)tblProducts_Categories with categoryID,productID column names Right now tblProducts_Categories table is empty. I want to insert data in categoryID,productID columns of tblProducts_Categories table where tblCategory.categoryName=tblProducts.productName and that tblProducts_Categories.productID<>tblProducts.productID CREATE PROCEDURE dbo.dt_populate_tblPrdCat AS Declare @s_catID integer Declare @s_prdID integer Declare CurRes CURSOR for SELECT c.categoryID,p.productID from tblCategory c,tblProducts p where c.categoryName=p.productName and c.parentID=5 and p.productID not in(select productID from tblProducts_Categories) OPEN CurRes FETCH NEXT FROM CurRes INTO @s_catID,@s_prdID WHILE @@FETCH_STATUS = 0 BEGIN EXEC('Insert into tblProducts_Categories(categoryID,productID) values(' + @s_catID + ',' + @s_prdID + ' )') FETCH NEXT FROM CurRes INTO @s_catID,@s_prdID END CLOSE CurRes DEALLOCATE CurRes GO |
![]() |
| Viewing: ASP Free Forums > Database > SQL Development > Stored procedure is taking lot of time to execute |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|