茫茫網海中的冷日 - 對這文章發表回應
茫茫網海中的冷日
         
茫茫網海中的冷日
發生過的事,不可能遺忘,只是想不起來而已!
 恭喜您是本站第 1675137 位訪客!  登入  | 註冊
主選單

Google 自訂搜尋

Goole 廣告

隨機相片
IMG_00141.jpg

授權條款

使用者登入
使用者名稱:

密碼:


忘了密碼?

現在就註冊!

對這文章發表回應

發表限制: 非會員 可以發表

發表者: 冷日 發表時間: 2019/4/17 9:02:28
RTRIM (Transact-SQL)

適用於: 是SQL Server (從 2008 開始) 是Azure SQL Database 是Azure SQL 資料倉儲 是平行處理資料倉儲

傳回截斷所有尾端空格的字元字串。

語法
RTRIM ( character_expression )


引數
character_expression

這是字元資料的運算式。 character_expression 可以是字元或二進位資料的常數、變數或資料行。

character_expression 必須是可以隱含轉換成 varchar 的資料類型。 否則,請使用 CAST 來明確轉換 character_expression。

傳回類型

varchar 或 nvarchar

範例
A. 簡單範例

下列範例會採用在句尾具有空格的字元字串,並且傳回句尾沒有空格的文字。
SELECT RTRIM('Removes trailing spaces.   ');


以下為結果集:
Removes trailing spaces.


B:簡單範例

下列範例會示範如何利用 RTRIM 來移除尾端空格。 這次,有另一個字串串連第一個字串,以顯示空格已消失。
SELECT RTRIM('Four spaces are after the period in this sentence.    ') + 'Next string.';


以下為結果集:
Four spaces are after the period in this sentence.Next string.


C. 使用 RTRIM 搭配變數

下列範例會示範如何利用 RTRIM 來移除字元變數中的尾端空白。
DECLARE @string_to_trim varchar(60);
SET @string_to_trim = 'Four spaces are after the period in this sentence.    ';
SELECT @string_to_trim + ' Next string.';
SELECT RTRIM(@string_to_trim) + ' Next string.';
GO


以下為結果集:
SQL

-------------------------------------------------------------------------
Four spaces are after the period in this sentence.     Next string.

(1 row(s) affected)`

-------------------------------------------------------------------------
Four spaces are after the period in this sentence. Next string.

(1 row(s) affected)


原文出處:RTRIM (Transact-SQL) - SQL Server | Microsoft Docs
內容圖示
url email imgsrc image code quote
樣本
bold italic underline linethrough   












 [詳情...]
validation picture

注意事項:
預覽不需輸入認證碼,僅真正發送文章時才會檢查驗證碼。
認證碼有效期10分鐘,若輸入資料超過10分鐘,請您備份內容後,重新整理本頁並貼回您的內容,再輸入驗證碼送出。

選項

Powered by XOOPS 2.0 © 2001-2008 The XOOPS Project|