dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersMore...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » .NET programming » General

Breaking a string in a store procedure


Posted Date:     Category: General    
Author: Member Level: Bronze    Points: 7



 


Suppose the company ids are coming in a string name @COMPANY_ID

BEGIN
DECLARE @CID VARCHAR(70)
DECLARE @Id varchar(max)
declare @Idd varchar(255)
declare @PN varchar(255)
declare @PNN varchar(255)
SET @CID = CONVERT(VARCHAR,@COMPANY_ID)
SET @PNN=''
Declare @CommaIndex varchar(10)
set @Idd=@search_key+','
While( @Idd <> '' or @Idd <> null )
BEGIN
SELECT @CommaIndex = PATINDEX('%,%', @Idd)
Select @PN = Substring(@Idd,1,@CommaIndex-1)
set @PN=+ ''''+ ''+ @PN +'' +''''+','
set @PNN=@PNN+@PN
Select @Idd = Substring(@Idd,PATINDEX('%,%', @Idd)+1
,len(@Idd))
if(@Idd is null)
begin
break
end





Did you like this resource? Share it with your friends and show your love!


Responses to "Breaking a string in a store procedure"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: OOPs Concepts in C#
    Previous Resource: Template Method Design Pattern - C#
    Return to Resources
    Post New Resource
    Category: General


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    (No tags found.)



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.