iT邦幫忙

1

MS SQL 取字串

XYZ 2022-02-11 16:17:32998 瀏覽
  • 分享至 

  • xImage

請問有2個資料33@yahoo.com.twqq33@yahoo.com.tw我要截取@前面的值, 該如何下指令?

33@yahoo.com.tw 截取--> 33
qq33@yahoo.com.tw 截取--> qq33

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

2
純真的人
iT邦大師 1 級 ‧ 2022-02-11 16:28:10
最佳解答

參考~

declare @Tmp table(
	Str nvarchar(50)
)

insert into @Tmp
values('33@yahoo.com.tw')
,('qq33@yahoo.com.tw')

select left(Str,charindex('@',Str)-1)
from @Tmp
where charindex('@',Str) > 0
XYZ iT邦新手 4 級 ‧ 2022-02-15 15:00:19 檢舉

謝謝您^^

我要發表回答

立即登入回答