久久久久久久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 個字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

考慮這樣一個場景,您希望從表中提取最后 x 個條目.我們想要的列包含有關(guān)產(chǎn)品的推薦.出于性能原因,我們只想從推薦中獲取前 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

這會產(chǎn)生一個錯誤:

參數(shù)數(shù)據(jù)類型文本無效左函數(shù)的參數(shù) 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

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

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

相關(guān)文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉(zhuǎn)換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創(chuàng)建視圖?)
Create calculated value based on calculated value inside previous row(根據(jù)前一行內(nèi)的計算值創(chuàng)建計算值)
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屋-程序員軟件開發(fā)技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉(zhuǎn)換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 国产精品免费一区二区三区四区 | 午夜影院网站 | 国产精品国产成人国产三级 | 福利视频网站 | 狠狠伊人 | 日韩国产免费观看 | 亚洲精品乱码久久久久久黑人 | 亚洲精品久久久 | 亚洲综合大片69999 | 国产精品污www一区二区三区 | 日本午夜视频 | 91在线精品秘密一区二区 | 久久一区精品 | 伊人春色在线观看 | 91在线综合 | 国产yw851.c免费观看网站 | 欧美日韩久久 | 成人精品国产 | 亚洲天堂中文字幕 | 成人在线黄色 | 亚洲色综合 | 狼人伊人影院 | 中文字幕在线视频一区二区三区 | 精品中文在线 | 亚洲国产一区二区三区在线观看 | 99国内精品久久久久久久 | 国产成人高清成人av片在线看 | 国产精品久久久久久久久久久久 | 91精品国产高清一区二区三区 | 午夜精品久久 | 爽爽免费视频 | 麻豆精品一区二区三区在线观看 | 国产精品国产精品国产专区不卡 | 四虎影视免费在线 | 国产小视频在线观看 | 精品熟人一区二区三区四区 | 亚洲精品中文字幕中文字幕 | 久久夜色精品国产 | 一区二区三区视频在线观看 | 欧美性猛交一区二区三区精品 | 亚洲国产成人精品女人久久久 |