SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 split string and return specific postion string
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kirank
Yak Posting Veteran

USA
52 Posts

Posted - 11/20/2013 :  01:41:14  Show Profile  Reply with Quote
SELECT
REPLACE(@ReqType ,'ALL', function call to split(string val, position) ) as [Request Type],
From
Temptable

Here i would create to call the function lets say SplitString with (string , position)
and return specific position string from that split result

ex:
1. dbo.splitfunction(Menu3_RI_ANCE_2013.docx,2) this will returns RI
2. dbo.splitfunction(Menu3_RI_ANCE_2013.docx,3) this will returns ANCE
like that..

Thanks for the help.



---------------------------

http://codingstuffsbykiran.blogspot.com | http://webdevlopementhelp.blogspot.com

khtan
In (Som, Ni, Yak)

Singapore
17436 Posts

Posted - 11/20/2013 :  01:48:35  Show Profile  Reply with Quote
use fnParseString() from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


KH
Time is always against us

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 11/20/2013 :  02:05:16  Show Profile  Reply with Quote
http://visakhm.blogspot.in/2010/02/parsing-delimited-string.html
http://visakhm.blogspot.in/2013/01/string-pattern-search-xml-based-method.html

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

kirank
Yak Posting Veteran

USA
52 Posts

Posted - 11/20/2013 :  02:33:26  Show Profile  Reply with Quote
quote:
Originally posted by khtan

use fnParseString() from http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=76033


KH
Time is always against us





Thanks, i did that using fnGetCsvPart function.

---------------------------

http://codingstuffsbykiran.blogspot.com | http://webdevlopementhelp.blogspot.com
Go to Top of Page

Jeff Moden
Aged Yak Warrior

USA
649 Posts

Posted - 11/23/2013 :  13:11:21  Show Profile  Reply with Quote
@kirank,

I'll recommend that if your string is 8k or less in length, then any splitter that contains any of the following is going to be comparatively slow to using a Tally CTE or Tally Table.

WHILE Loop
Recursive CTE
Concatenation of any type
XML (exception is if you're passing the function XML)

With that thought in mind, how long are the strings that you wish to split and get the element number for?

--Jeff Moden
RBAR is pronounced "ree-bar" and is a "Modenism" for "Row By Agonizing Row".

First step towards the paradigm shift of writing Set Based code:
"Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

When writing schedules, keep the following in mind:
"If you want it real bad, that's the way you'll likely get it."

Edited by - Jeff Moden on 11/23/2013 13:11:56
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000