Hi, I am looking forward to write a stored procedure that will replace all the commas (,) in a column for a given table. e.g., I have a table that has a column called sports with values say 'cricket,badminton,volleyball,baseball,skiing' There are several rows and that particular column has values like these. I want to remove these commas and the value should look like say ''cricketbadmintonvolleyballbaseballskiing' i.e., I want to eliminate the commas. Can anyone help me out. Thanks, StarWarsBigBang
There is a replace function in sql server Select replace('cricket,badminton,volleyball,baseball,skiing',',','') Chirag http://chirikworld.blogspot.com/
Thanks Frank and Chirag, I am aware of the replace function. Using your above method, I will have to manually update the values. The table has several rows with commas in the sports column. Any idea how these can be done through stored procedures. Thanks, StarWarsBigBang
Update TAbleName Set SportColumn = Replace(SportColumn,',','') ?? Chirag http://chirikworld.blogspot.com/
UPDATE your_table SET your_column = REPLACE(your_column, ',', '') That's just a single statement taking care of all rows in your_table. -- Frank Kalis Moderator Microsoft SQL Server MVP Webmaster:http://www.insidesql.de
Frank, Chirag seems faster [<img src='/community/emoticons/emotion-2.gif' alt='' />]<br /><br />StarWarsBigBang, Learn SQL<br /<a target="_blank" href=http://www.sql-tutorial.net/>http://www.sql-tutorial.net/</a> <br /<a target="_blank" href=http://www.firstsql.com/tutor.htm>http://www.firstsql.com/tutor.htm</a> <br /<a target="_blank" href=http://www.w3schools.com/sql/default.asp>http://www.w3schools.com/sql/default.asp</a> <br /><br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Madhivanan</i><br /><br />Frank, Chirag seems faster [<img src='/community/emoticons/emotion-2.gif' alt='' />]<br /><br />StarWarsBigBang, Learn SQL<br /<a target="_blank" href=http://www.sql-tutorial.net/>http://www.sql-tutorial.net/</a> <br /<a target="_blank" href=http://www.firstsql.com/tutor.htm>http://www.firstsql.com/tutor.htm</a> <br /<a target="_blank" href=http://www.w3schools.com/sql/default.asp>http://www.w3schools.com/sql/default.asp</a> <br /><br /><br />Madhivanan<br /><br />Failing to plan is Planning to fail<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br /><br /><br />Great, Thanks for the link.
<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote"><i>Originally posted by Madhivanan</i><br /><br />Frank, Chirag seems faster [<img src='/community/emoticons/emotion-2.gif' alt='' />]<br /><hr height="1" noshade id="quote"></font id="quote"></blockquote id="quote"><br />Yes, this time...[8D]<br /><br />--<br />Frank Kalis<br />Moderator<br />Microsoft SQL Server MVP<br />Webmaster:<a target="_blank" href=http://www.insidesql.de>http://www.insidesql.de</a>