久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

T-SQL:從 text 或 ntext 列中選擇前 n 個字符

T-SQL: Selecting top n characters from a text or ntext column(T-SQL:從 text 或 ntext 列中選擇前 n 個字符)
本文介紹了T-SQL:從 text 或 ntext 列中選擇前 n 個字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

考慮這樣一個場景,您希望從表中提取最后 x 個條目.我們想要的列包含有關產品的推薦.出于性能原因,我們只想從推薦中獲取前 50 個字符.該列名為 TestimonialText,類型為 text.

Consider a scenario where you'd like to pull the last x entries from a table. The column we want contains testimonials about a product. For performance reasons, we only want to grab the first 50 characters from the testimonial. The column is named TestimonialText and is of type text.

考慮這個 T-SQL 的精簡片段:

Consider this condensed snippet of T-SQL:

SELECT TOP 10
    C.FirstName + ' ' + C.LastName AS CustomerName
    ,LEFT(C.TestimonialText,50) AS TestimonialSnippet
    ,C.TestimonialDate

FROM Customer AS C  
ORDER BY C.TestimonialDate DESC

這會產生一個錯誤:

參數數據類型文本無效左函數的參數 1.

Argument data type text is invalid for argument 1 of left function.

問題:如何只提取 text 或 ntext 列的前幾個 n 個字符?

Question: how to extract just the first few n characters of the text or ntext column?

推薦答案

我認為 SUBSTRING 是更好的選擇.試試這個:

I think SUBSTRING would be a better choice. Try this:

SELECT TOP 10
    C.FirstName + ' ' + C.LastName AS CustomerName
    ,SUBSTRING(C.TestimonialText,1,50) AS TestimonialSnippet
    ,C.TestimonialDate
FROM Customer AS C  
ORDER BY SUBSTRING(C.TestimonialText,1,50) DESC

這篇關于T-SQL:從 text 或 ntext 列中選擇前 n 個字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 国产区一区| 亚洲精品在线免费观看视频 | 欧美综合在线观看 | 91精品一区二区三区久久久久久 | 成人亚洲网站 | 99久久精品国产毛片 | 成人网视频 | 超碰日韩 | 综合中文字幕 | 国产在线观看一区 | 四虎永久 | 中文字幕av在线播放 | 欧美另类视频 | 在线免费观看视频你懂的 | 欧洲妇女成人淫片aaa视频 | 九九导航 | 国产精品99久久久久久动医院 | 在线看一区二区三区 | 久久婷婷麻豆国产91天堂 | h视频免费在线观看 | 精品网站999www | 精品国产成人 | 在线日韩av电影 | 中文字幕亚洲欧美日韩在线不卡 | 欧美福利影院 | www.日韩| 国产精品久久久久一区二区三区 | 黄色av网站在线免费观看 | 中文字幕在线免费观看 | 免费在线一区二区 | 亚洲欧美视频一区二区 | 精品久久久久久久久久久 | 久久亚洲视频 | 欧美激情久久久久久 | 涩涩视频网站在线观看 | 天天色天天色 | 亚洲美女在线一区 | 久久久美女 | 国产精品欧美一区二区三区 | 酒色成人网 | h视频在线免费 |