沒有
創(chuàng)新互聯(lián)建站專注于團(tuán)風(fēng)企業(yè)網(wǎng)站建設(shè),成都響應(yīng)式網(wǎng)站建設(shè)公司,成都做商城網(wǎng)站。團(tuán)風(fēng)網(wǎng)站建設(shè)公司,為團(tuán)風(fēng)等地區(qū)提供建站服務(wù)。全流程按需求定制開發(fā),專業(yè)設(shè)計,全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
你可以嘗試這樣
declare @searchstr varchar(max)
declare @valuestr varchar(max)
declare @index int
--結(jié)果表達(dá)試出現(xiàn)次數(shù)
declare @count int
--要搜索的表達(dá)式
set @searchstr = '111111abc2222222abc333333abc44444555'
--搜索表達(dá)試
set @valuestr = 'abc'
set @count = 0
select @index = charindex(@valuestr,@searchstr,0)
while @index0
begin
set @count = @count + 1
select @searchstr = substring(@searchstr,@index+len(@valuestr),len (@searchstr))
select @index = charindex(@valuestr,@searchstr,0)
end
select @count
要是表格里沒有拼音的話不可能直接根據(jù)中文提取首字母的。EXCEL和SQL還沒智能化到如此
--?SQLServer:
---測試數(shù)據(jù)---
if?object_id('[pactinfo]')?is?not?null?drop?table?[pactinfo]
go
create?table?[pactinfo]([ID]?int,[pactname]?varchar(4))
insert?[pactinfo]
select?1,'正常'?union?all
select?2,'中國'?union?all
select?3,'做飯'?union?all
select?4,'加發(fā)'
---引用前輩們的一個函數(shù)---
create?function???f_GetPy(@str???nvarchar(4000))?
returns???nvarchar(4000)?
as?
begin?
declare???@strlen???int,@re???nvarchar(4000)?
declare???@t???table(chr???nchar(1)???collate???Chinese_PRC_CI_AS,letter???nchar(1))?
insert???into???@t(chr,letter)?
select???'吖?',?'A?'???union???all???select???'八?',?'B?'???union???all?
select???'嚓?',?'C?'???union???all???select???'咑?',?'D?'???union???all?
select???'妸?',?'E?'???union???all???select???'發(fā)?',?'F?'???union???all?
select???'旮?',?'G?'???union???all???select???'鉿?',?'H?'???union???all?
select???'丌?',?'J?'???union???all???select???'咔?',?'K?'???union???all?
select???'垃?',?'L?'???union???all???select???'嘸?',?'M?'???union???all?
select???'拏?',?'N?'???union???all???select???'噢?',?'O?'???union???all?
select???'妑?',?'P?'???union???all???select???'七?',?'Q?'???union???all?
select???'呥?',?'R?'???union???all???select???'仨?',?'S?'???union???all?
select???'他?',?'T?'???union???all???select???'屲?',?'W?'???union???all?
select???'夕?',?'X?'???union???all???select???'丫?',?'Y?'???union???all?
select???'帀?',?'Z?'?
select???@strlen=len(@str),@re=?'?'?
while???@strlen?0?
begin?
select???top???1???@re=letter+@re,@strlen=@strlen-1?
from???@t???a???where???chr?=substring(@str,@strlen,1)?
order???by???chr???desc?
if???@@rowcount=0?
select???@re=substring(@str,@strlen,1)+@re,@strlen=@strlen-1?
end?
return(@re)?
end?
---查詢---
select?
*?
from?
[pactinfo]
where
left(dbo.f_GetPy(pactname),1)='Z'
---結(jié)果---
ID??????????pactname?
-----------?--------?
1???????????正常
2???????????中國
3???????????做飯
(所影響的行數(shù)為?3?行)
新聞標(biāo)題:sqlserver拼音檢索函數(shù),sql生成拼音碼
URL標(biāo)題:http://jinyejixie.com/article42/dsecjhc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站建設(shè)、網(wǎng)站收錄、Google、小程序開發(fā)、服務(wù)器托管、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)