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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Split function with cursor

Author  Topic 

shakthiA
Starting Member

12 Posts

Posted - 2008-04-07 : 11:00:19
Hi,
I am trying to write a stored procedure that takes a comma separated letter. I have a split function that returns the splitted letters. I have select some values from the tables in the database where the title starts with each splitted letter. I thought I should use cursor that contains each letter and in the while loop i put my select statement with the conditions.
Is this the correct way. Or are there any ideas for this?

thanks,

Regards,
shakthi

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-07 : 11:43:34
Hi shakthi,

You will get good answers quicker if you...

1. Give the DDL - e.g. CREATE TABLE t1 (c1 INT, ...)
2. Give sample data for that DDL. Choose data which will demonstrate your various scenarios.
3. Give the results you would want from that sample data


Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2008-04-07 : 12:00:41
Presumably your split function returns a table so
select t.*
from titles
join (select letter from dbo.split(@mycsvstring) a
on a.letter = left(titles.title,1)

Note - you no longer need a split function with v2005 as you can write an in-line cte.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -