开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜