小编Wil*_*yer的帖子

在搜索TEXT列中的空格时,CHARINDEX始终返回0

--get text target starting integers into a table

declare @target TABLE([USERID] varchar(25),[target] int)

--get text stopping point integers into a table

declare @stop TABLE([USERID] varchar(25),[target] int, [stop] int)

--get just the options I want into a table

declare @options TABLE ([USERID] varchar(25), [userDetails] text)
insert into @options ([userid], [userDetails])
select u.userid, rtrim(ltrim(SUBSTRING([userDetails], s.[target], s.[stop] - s.[target])))
from users u join @stop s on u.userid = s.userid

declare @userDetails varchar(max)
Select top 1
@userDetails = [userDetails]
from @options
select charindex(char(32), @userDetails) …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server sql-server-2008-r2

5
推荐指数
1
解决办法
5839
查看次数

标签 统计

sql ×1

sql-server ×1

sql-server-2008-r2 ×1

t-sql ×1