달력

52024  이전 다음

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
반응형

-- 테스트환경.

 

CREATE TABLE Test

(A varchar(1000) NULL)

GO

 

 

INSERT Test (A)

VALUES ('asdfdas.jpg<script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script>')

GO

 

INSERT Test (A)

VALUES ('asdfadsf.zip<script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script>')

GO

 

 

INSERT Test (A)

VALUES ('dfdasfdasf.jpgsdkaf')

GO

 

INSERT Test (A)

VALUES ('dsfasfdasf.zipdedfg')

GO

 

SELECT * FROM Test

GO

 

/*

 

asdfdas.jpg<script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script>

 

asdfadsf.zip<script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script><script src=http://dae3.cn></script>

 

dfdasfdasf.jpgsdkaf

 

dsfasfdasf.zipdedfg

 

*/

 

 

/* 반복되는스크립트가일정할때.  컬럼이TEXT 타입인경우, VARCHAR 으로형변환후함.

SQL Server 2000 의경우VARCHAR(8000) 이최대길이이므로, 최대길이는비교해보고해야함

*/

UPDATE Test

SET A = REPLACE(CONVERT(VARCHAR(8000),A) , '<script src=http://dae3.cn></script>', '')

 

 -- 반복되는스크립트가일정하지않고, 특정파일뒤에만짜르고싶은경우. 컬럼이TEXT 일경우

UPDATE Test

SET A = LEFT(CONVERT(VARCHAR(8000),A),CHARINDEX( '.jpg',CONVERT(VARCHAR(8000),A))+3)

WHERE  CHARINDEX( '.jpg',CONVERT(VARCHAR(8000),A)) > 0

 

 

UPDATE Test

SET A = LEFT(CONVERT(VARCHAR(8000),A),CHARINDEX( '.zip',CONVERT(VARCHAR(8000),A))+3)

WHERE  CHARINDEX( '.zip',CONVERT(VARCHAR(8000),A)) > 0

 

 

-- 반복되는스크립트가일정할때. 컬럼이그냥일반char , varchar 등일경우.

UPDATE Test

SET A = REPLACE(A , '<script src=http://dae3.cn></script>', '')

 

-- 반복되는스크립트가일정하지않고, 특정파일뒤에만짜르고싶은경우.

UPDATE Test

SET A = LEFT(A,CHARINDEX( '.jpg',A)+3)

WHERE  CHARINDEX( '.jpg',A) > 0

 

UPDATE Test

SET A = LEFT(A,CHARINDEX( '.zip',A)+3)

WHERE  CHARINDEX( '.zip',A) > 0

 

 

/*

asdfdas.jpg

asdfadsf.zip

dfdasfdasf.jpg

dsfasfdasf.zip

*/

 

반응형
Posted by 친절한 웬디양~ㅎㅎ
|