Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

help with Store procedure Expand / Collapse
Author
Message
Posted Friday, March 22, 2013 10:45 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 14, 2013 8:21 AM
Points: 4, Visits: 16
hi guys,

can anyone help me

1.i need to Write a SP to accept comma separated values and return as list of string values
2. i need to Write a SP to find occurences of a character in a string
3. i need to Write a SP to find number of words in a sentence

Post #1434392
Posted Friday, March 22, 2013 12:11 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Tuesday, August 19, 2014 1:58 PM
Points: 367, Visits: 615
Sounds like homework to me.
Post #1434454
Posted Friday, March 22, 2013 12:17 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 14, 2013 8:21 AM
Points: 4, Visits: 16
Am trying to practice but I didn't can you help me
Post #1434457
Posted Friday, March 22, 2013 12:27 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: 2 days ago @ 4:49 PM
Points: 866, Visits: 7,478
There are some excellent string splitter functions you can search for on this site (Jeff Moden's is the one most recommended for speed and flexibility). Any of these would be good illustrations of the concepts you need to solve your exercises. Posting what you have tried so far will allow the folks here to steer you in the right direction without doing the work for you. Most folks here balk at providing the complete answer for these types of exercises because it tends to minimize the actual amount of knowledge gained by the requestor.



And then again, I might be wrong ...
David Webb
Post #1434468
Posted Friday, March 22, 2013 12:32 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: 2 days ago @ 11:35 AM
Points: 4,482, Visits: 3,938
For #1 and #3, try Jeff Moden's string splitter. http://www.sqlservercentral.com/articles/Tally+Table/72993/

For #2, Sean Lange posted this great approach earlier today for a similar request:

with EconSearch(SomeValue) as
(
select 'D.01.01.01' union all
select 'D.01.01.02' union all
select 'D.01.01.03' union all
select 'D.01.01.03.00'
)

select len(SomeValue) - len(Replace(SomeValue, '.', '')) as NumberOfPeriods
from EconSearch




Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Post #1434472
Posted Friday, March 22, 2013 12:34 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 9:10 AM
Points: 13,230, Visits: 12,709
Yes splitting your parameter is the way to go here. All of these can easily be done using Jeff's splitter. You can find it by following the link in my signature for splitting strings.

_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1434474
Posted Friday, March 22, 2013 12:36 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 9:10 AM
Points: 13,230, Visits: 12,709
Ed Wagner (3/22/2013)
For #1 and #3, try Jeff Moden's string splitter. http://www.sqlservercentral.com/articles/Tally+Table/72993/

For #2, Sean Lange posted this great approach earlier today for a similar request:

with EconSearch(SomeValue) as
(
select 'D.01.01.01' union all
select 'D.01.01.02' union all
select 'D.01.01.03' union all
select 'D.01.01.03.00'
)

select len(SomeValue) - len(Replace(SomeValue, '.', '')) as NumberOfPeriods
from EconSearch



Thanks Ed. As soon as I posted I suddenly had that feeling that I just posted to the wrong thread having seen code that looked eerily familiar.


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1434476
Posted Friday, March 22, 2013 12:37 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 7:21 AM
Points: 7,135, Visits: 12,749
1.i need to Write a SP to accept comma separated values and return as list of string values

If you're on SQL 2008 or above then why would you ever want to do that when you can use a Table-Valued Parameter?

Table-Valued Parameters (Database Engine) - SQL Server 2008


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato
Post #1434477
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse