Weird not sure if I have it correct but the output is weird:
select *
into #TempScormModuelsTable
from Scorm.ScormModules
select * from #TempScormModuelsTable
DECLARE @ScormModuleId int
DECLARE db_cursor CURSOR FOR
SELECT ScormModuleId from #TempScormModuelsTable
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @ScormModuleId
WHILE @@FETCH_STATUS = 0
BEGIN
update #TempScormModuelsTable
set Directory = REPLACE(Directory,'SCORM','ScormPackages'),
RelativeHtmlPath = REPLACE(RelativeHtmlPath,'SCORM','ScormPackages')
FETCH NEXT FROM db_cursor INTO @ScormModuleId
END
--drop table #TempScormModuelsTable
CLOSE db_cursor
DEALLOCATE db_cursor
then in the column Directory I have this!
E:\inetpub\www.sellandprosper.com\ScormPackagesPackagesPackagesPackagesPackagesPackagesPackagesPackages\SellingOfficeWithNewPCs
“ScormPackagesPackagesPackagesPackagesPackagesPackagesPackagesPackages” was “SCORM” and I just want it as ScormPackages..yikes
any help?
That’s not SQL.
You need something closer to…
SQL is already set based and this will naturally apply this to every row (much like your FOREACH pseudocode).
I’m not sure what your
WHEREclause is meant to do, but you can appendWHEREclauses toUPDATEs too.EDIT
Okay you just totally changed the code in your question.
Now, you’re looking in a cursor, but the update is being done to the whole table.
So, if you have 8 rows, you do the update 8 times. But each time you do it to every row in the table.