declare @ss varchar(300)
declare @csr CURSOR
set @csr=cursor for
select statpartno from catalog where flag=2
open @csr
fetch next from @csr
--print @@FETCH_STATUS
while @@FETCH_STATUS=0
begin
fetch next from @csr into @ss
print @ss+'|'
--=====================================
declare @a VARCHAR(8000)
set @a=@ss
DECLARE @SubStr VARCHAR(8000)
set @a=rtrim(@a)
SET @SubStr = LEFT(@a,CHARINDEX('-',@a,0)-1)
SET @a = RIGHT(@a,Len(@a)-CHARINDEX('-',@a,0))
SET @SubStr = LEFT(@a,CHARINDEX('-',@a,0)-1)
SET @a = RIGHT(@a,Len(@a)-CHARINDEX('-',@a,0)-1)
Set @subStr=right('000000'+@a,6)
print @SubStr
--=====================================
end
close @csr
deallocate @csr
--dbo.getDistance 'FTM-8020C-S'