sql 줄 바 꾸 기

3223 단어 sql
다음으로 전송:http://blog.csdn.net/ljsososo/article/details/10378573
풍부 한 텍스트 내용 중 에는 통상 적 으로 차 를 되 돌리 고 줄 을 바 꾸 는 내용 이 나타난다.sql 데이터베이스 에서 이 리 턴, 줄 바 꿈 자 는 html 를 출력 한 후 빈 칸 으로 표 시 됩 니 다.
여 기 는 데이터 내 보 내기, 가 져 오기 에서 발 견 된 것 입 니 다. 보통 리 턴, 줄 바 꿈 자 를 찾 아 < br > 로 교체 합 니 다. 
여기 'sql 함수' 를 사 용 했 습 니 다.replace (string expression, string pattern, string replacement), 첫 번 째 매개 변수: 찾 을 필드.두 번 째 인자: 찾 을 문자 입 니 다.세 번 째 인자: 바 꿀 문자 입 니 다.
char(9)      
char(10)   
char(13)   

1 > 리 턴 부적 char(13)
SELECT *, REPLACE (detail, CHAR (13), '< br >') AS 는 교 체 된 내용 을 보 여 줍 니 다 FROM Test
2 > 줄 바 꾸 기
SELECT *, REPLACE (detail, CHAR (10), '< br >') AS 는 교 체 된 내용 을 보 여 줍 니 다 FROM Test
3 > 리 턴 줄 바 꾸 기
SELECT *, REPLACE (detail, CHAR (13) + CHAR (10), '< br >') AS 는 교 체 된 내용 을 보 여 줍 니 다 FROM Test
4 > Enter 줄 바 꾸 기 를 < BR > < BR > 로 바 꿉 니 다.
UPDATE TestSET detail = REPLACE(detail, CHAR(13) + CHAR(10), '

') 
update t_news set content=REPLACE(content, CHAR(13) + CHAR(10), '

') where news_type=3
내용 앞 에 두 개의 빈 칸, 전각 의 update tnews set content='  '+content where news_type=3
===========================
어떻게 sql 문 구 를 사용 하여 한 필드 에 줄 바 꿈 문자 가 있 는 지 판단 합 니까?
 
select * from    where instr(   ,chr(13))>0
  chr(13)     。

sql server 2000 에 서 는 인 스 턴 트 가 지원 되 지 않 습 니 다. 함수 가 인 스 터 를 charindex 로 바 꾸 면 됩 니 다.
charindex    
 、  
CHARINDEX ( char1 ,string1 [ , start_location ] ) 
   char1   string1     Unicode     (nvarchar   nchar)      ,         Unicode     。CHARINDEX     text、ntext   image         。
   char1   string1     NULL,           70    ,  CHARINDEX     NULL。           65    ,  CHARINDEX     char1   string1    NULL      NULL  。
    char1      string1,  CHARINDEX    0。
char1       ,             。
string1       ,              。string1          。
start_location      string1     char1       。
   start_location     、       ,    string1        。start_location     bigint   。
 string1     char1        
 string1      char1    0
 、  
USE AdventureWorks
SELECT CHARINDEX('bicycle', DocumentSummary)
FROM Production.Document
WHERE DocumentID = 3;
     48。
SELECT CHARINDEX('bicycle1', DocumentSummary, 5)
FROM Production.Document
WHERE DocumentID = 3;
     0。
  DocumentSummary     "bicycle"    。
          :
select * from Production.Document
 where DocumentSummary like'%bicycle%'
        ,       :
select * from Production.Document 
where charindex('bicycle',DocumentSummary)>0      like'%%'          .
              sql 2005   .

좋은 웹페이지 즐겨찾기