I am trying to loop through all records in a coloumn and determine if a record has a file extension or not. If it does I want to run select statement A if it doesn't then select statement B. But I can't seem to make it work in my cursor. I've never used a cursor before and I assume my syntax for the IF statement must be wrong. Is this the best way to try and do it? This is what I have so far:
DECLARE @extension int
DECLARE extension CURSOR for
SELECT charindex('.', reverse(tblImportObject.URI))
FROM tblImportObject
WHERE SiteID<>1
OPEN extension
FETCH NEXT FROM extension INTO @extension
WHILE @@FETCH_STATUS = 0
BEGIN
IF(@extension < 1)
SELECT Title
FROM tblImportObject
WHERE SiteID <>1
FETCH NEXT FROM EXTENSION INTO @extension
ELSE
SELECT SiteID
FROM tblImportObject
WHERE SiteID<>1
FETCH NEXT FROM EXTENSION INTO @extension
END
CLOSE extension
DEALLOCATE extension
Thanks in advance for any advice.
DECLARE @extension int
DECLARE extension CURSOR for
SELECT charindex('.', reverse(tblImportObject.URI))
FROM tblImportObject
WHERE SiteID<>1
OPEN extension
FETCH NEXT FROM extension INTO @extension
WHILE @@FETCH_STATUS = 0
BEGIN
IF(@extension < 1)
SELECT Title
FROM tblImportObject
WHERE SiteID <>1
FETCH NEXT FROM EXTENSION INTO @extension
ELSE
SELECT SiteID
FROM tblImportObject
WHERE SiteID<>1
FETCH NEXT FROM EXTENSION INTO @extension
END
CLOSE extension
DEALLOCATE extension
Thanks in advance for any advice.