SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


help with Store procedure


help with Store procedure

Author
Message
aslamshaik6
aslamshaik6
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
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
jerry-621596
jerry-621596
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1345 Visits: 649
Sounds like homework to me.
aslamshaik6
aslamshaik6
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 16
Am trying to practice but I didn't can you help me
David Webb-CDS
David Webb-CDS
SSCarpal Tunnel
SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)SSCarpal Tunnel (4.1K reputation)

Group: General Forum Members
Points: 4108 Visits: 8586
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
Ed Wagner
Ed Wagner
SSC-Forever
SSC-Forever (49K reputation)SSC-Forever (49K reputation)SSC-Forever (49K reputation)SSC-Forever (49K reputation)SSC-Forever (49K reputation)SSC-Forever (49K reputation)SSC-Forever (49K reputation)SSC-Forever (49K reputation)

Group: General Forum Members
Points: 49577 Visits: 10844
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
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63338 Visits: 17966
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 Modens 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)
Sean Lange
Sean Lange
SSC Guru
SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)SSC Guru (63K reputation)

Group: General Forum Members
Points: 63338 Visits: 17966
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. :-P

_______________________________________________________________

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 Modens 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)
Orlando Colamatteo
Orlando Colamatteo
SSC-Forever
SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)SSC-Forever (40K reputation)

Group: General Forum Members
Points: 40232 Visits: 14413
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
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search