Link to home
Start Free TrialLog in
Avatar of VBdotnet2005
VBdotnet2005Flag for United States of America

asked on

Loop string and update table

Could you show me how to split @username (by ',') and update table for each item in sql.

Declare @username varchar(100)
set @username = 'Jim, 'John, 'Dave'

Update table set username = ? where user = @username
Avatar of VBdotnet2005
VBdotnet2005
Flag of United States of America image

ASKER

Any thoughts Experts?
Avatar of sarabande
you can have a where clause like

where user in ('Jim, 'John, 'Dave')

Open in new window


what probably is what you intend to do.

however the update table statement doesn't make any sense cause you rarely want to update the user name to a value it already has (since you searched for it).

Sara
ASKER CERTIFIED SOLUTION
Avatar of x-men
x-men
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please provide more information.
your string looks funny
Why is "Visual Basic.NET" one of the topics on this question? It appears to be a pure SQL question. Or are you looking to do it either in SQL or VB.NET?
thanks x-men, this is exactly what I was looking for.