VBdotnet2005
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
Declare @username varchar(100)
set @username = 'Jim, 'John, 'Dave'
Update table set username = ? where user = @username
you can have a where clause like
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
where user in ('Jim, 'John, 'Dave')
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
ASKER
thanks x-men, this is exactly what I was looking for.
ASKER