how can I can update a table ::
I must get all the left part of a columns part1_part2
I dont know how many characters
something like :
UPDATE Users SET Users.Info = left(Users.name, _ ? or split('_'))
in that case Users.name = part1
i must update only the one with a '_' and do nothing for the others
thank youTry variations of these to get what you want:
declare @.Name varchar(50)
set @.Name = 'Part1Part2'
select left(@.Name, charindex('_', @.Name + '_')-1)
select substring(@.Name, charindex('_', @.Name + '_')+1, 50)
...or if the names are more complex (such as including middle names, initials, or titles), I have a name splitting function I can give you.|||thank you BlindMan
but the name of the column is Users.Name and part1_part2 was an exemple of value
in that exemple i must get part1
it could be werfewgf fff jjj_rgfregreg
and in that case i must get werfewgf fff jjj
allways the left part of '_'|||with select substring(Users.Name, charindex('_', Users.Name + '_')+1, 50) FROM Users
I get exactly the right part
the left will be great :-)
but I get all even if there is no '_'|||Can you supply some sample data and what the expect result is suppose to be?
My esp usb port is clogged|||sample data >> expect result
wefwefqrwf_hhhh >> wefwefqrwf
fff jj ff_rgdefrhbg >> fff jj ff
acacac145 i4_kk >> acacac145 i4
dddd >> no result, I dont take it there is no _ in the sample data
thanks Brett
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment