3초기억력

MS-SQL- 프로시저, split 효과 본문

쿼리_MSSQL

MS-SQL- 프로시저, split 효과

잠수콩 2010. 3. 30. 18:12




set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go

ALTER PROCEDURE [dbo].[SP_ConfigDel]
@returnv int output,
@DATA VARCHAR(1000)
AS
BEGIN
 BEGIN TRAN
WHILE CHARINDEX(',',@DATA)<>0
  BEGIN
       
 
        Update TB_ConfigData set SFlg='N' , SFlgDate=getdate() where IDX=SUBSTRING(@DATA,1,CHARINDEX(',',@DATA)-1)
        SET @DATA=SUBSTRING(@DATA,CHARINDEX(',',@DATA)+1,LEN(@DATA))               
  IF CHARINDEX(',',@DATA)=0
           BREAK
  ELSE
           CONTINUE
 
  END
 
END
 if @@ERROR = 0
  BEGIN
  COMMIT TRAN
  set @returnv = 1
  END
 else
  BEGIN
  ROLLBACK TRAN
  set @returnv = 2
  END
Comments