开发者

How to select part of the string with T-SQL?

开发者 https://www.devze.com 2023-03-07 16:18 出处:网络
I have a string comma delimited. I need to select with t-sql just first part of it. Example table iditemsvalues

I have a string comma delimited. I need to select with t-sql just first part of it.

Example

table

id                   items                              values    
1                    item, item2, item3, item4          5

I need to get result like

ID                    Items      开发者_StackOverflow社区       Values
1                     item              5


Try this one

select id, 
       substring(items,0,charindex(',',items)),
       values 
from mytable
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号