Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jgandara
Starting Member
18 Posts |
Posted - 2004-03-12 : 15:57:11
|
| I have a store procedure where I have several items from which i need to parse a string to count a specific character. My code looks like this:SELECT @count=1while @count<31 BEGIN If Substring(@Text,@count,1) ='-' Select @Count2=Count2+1 SET @count=@count+1 ENDAny idea if it's a bug? or there is another better way to do it? |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-03-12 : 16:02:03
|
| [code]DECLARE @x varchar(8000), @y int, @z char(1)SELECT @x = 'SQL-Server-2005-Release-Date-Is-Set-For-2010', @z = '-'SELECT @y = LEN(@x)-LEN(REPLACE(@x,'-',''))SELECT @y[/code]Brett8-) |
 |
|
|
jgandara
Starting Member
18 Posts |
Posted - 2004-03-12 : 16:52:39
|
| Thx for your solution, it looks very good. I have a SQL server 6.5 book and I didn't see the Replace function. As for the problem, I was putting some print statements, at the beggining end end of the loop, and I didn't see the print at the end.I traced the execution on SQL Query Analizer and noticed that it was somewhere else where the SP was getting hung, it was a query where I try to update a lot of records at a time.Well thank you anyways. |
 |
|
|
|
|
|