Click here to Skip to main content
15,890,123 members
Home / Discussions / Database
   

Database

 
QuestionHow can i extract numeric values from varchar Pin
snehasish15-Dec-08 19:57
snehasish15-Dec-08 19:57 
AnswerRe: How can i extract numeric values from varchar Pin
Blue_Boy15-Dec-08 23:11
Blue_Boy15-Dec-08 23:11 
GeneralRe: How can i extract numeric values from varchar Pin
snehasish16-Dec-08 2:26
snehasish16-Dec-08 2:26 
GeneralRe: How can i extract numeric values from varchar Pin
Blue_Boy16-Dec-08 5:18
Blue_Boy16-Dec-08 5:18 
GeneralRe: How can i extract numeric values from varchar Pin
snehasish16-Dec-08 8:31
snehasish16-Dec-08 8:31 
GeneralRe: How can i extract numeric values from varchar Pin
Blue_Boy16-Dec-08 11:12
Blue_Boy16-Dec-08 11:12 
QuestionSplit the Delimiters Pin
cbe_pav15-Dec-08 18:39
cbe_pav15-Dec-08 18:39 
AnswerRe: Split the Delimiters Pin
Ashfield15-Dec-08 21:05
Ashfield15-Dec-08 21:05 
There is no easy way to do this as SQL doesn't have a split function built in, so you have to roll your own. Here is one way.


CREATE FUNCTION [dbo].[fn_DelimitedSplit] 
(
@TextToSplit VARCHAR(8000), @Delimiter VARCHAR(255)
)
RETURNS @SplitKeyword TABLE (Keyword VARCHAR(8000),seq int identity)
AS
BEGIN
 DECLARE @Word VARCHAR(255)

 WHILE (CHARINDEX(@Delimiter, @TextToSplit, 1)>0)
 BEGIN
  SET @Word = SUBSTRING(@TextToSplit, 1 , CHARINDEX(@Delimiter, @TextToSplit, 1) - 1)
  SET @TextToSplit = SUBSTRING(@TextToSplit, CHARINDEX(@Delimiter, @TextToSplit, 1) + 1, LEN(@TextToSplit))
  INSERT INTO @SplitKeyword(Keyword) VALUES(@Word)
 END
 
 INSERT INTO @SplitKeyword(Keyword) VALUES(@TextToSplit)
 return
END



You can then use it like so:

Declare @Code vatrchar(50)
set @Code = 'a_b_c'
select Keyword,seq from dbo.fn_DelimitedSplit(@Code,'_')



Hope this helps

Bob
Ashfield Consultants Ltd

QuestionGet the following query down to one execution Pin
Sunset Towers15-Dec-08 11:03
Sunset Towers15-Dec-08 11:03 
AnswerRe: Get the following query down to one execution Pin
Wendelius15-Dec-08 11:16
mentorWendelius15-Dec-08 11:16 
GeneralRe: Get the following query down to one execution Pin
Sunset Towers15-Dec-08 12:00
Sunset Towers15-Dec-08 12:00 
GeneralRe: Get the following query down to one execution Pin
Wendelius16-Dec-08 5:51
mentorWendelius16-Dec-08 5:51 
QuestionQuestion about "stalled" snapshot in an Oracle database Pin
Nostrom015-Dec-08 9:46
Nostrom015-Dec-08 9:46 
AnswerRe: Question about "stalled" snapshot in an Oracle database Pin
Wendelius15-Dec-08 10:31
mentorWendelius15-Dec-08 10:31 
QuestionRelocate the datbase Pin
samerh15-Dec-08 0:53
samerh15-Dec-08 0:53 
AnswerRe: Relocate the datbase Pin
Colin Angus Mackay15-Dec-08 3:03
Colin Angus Mackay15-Dec-08 3:03 
QuestionTrigger error. help me plz Pin
Karan_TN14-Dec-08 19:37
Karan_TN14-Dec-08 19:37 
AnswerRe: Trigger error. help me plz Pin
Ashfield14-Dec-08 21:29
Ashfield14-Dec-08 21:29 
AnswerRe: Trigger error. help me plz Pin
Colin Angus Mackay14-Dec-08 23:20
Colin Angus Mackay14-Dec-08 23:20 
QuestionJoining two columns together Pin
Muammar©13-Dec-08 20:23
Muammar©13-Dec-08 20:23 
AnswerRe: Joining two columns together Pin
Mycroft Holmes13-Dec-08 20:37
professionalMycroft Holmes13-Dec-08 20:37 
AnswerRe: Joining two columns together Pin
Mycroft Holmes13-Dec-08 20:38
professionalMycroft Holmes13-Dec-08 20:38 
GeneralRe: Joining two columns together Pin
Muammar©13-Dec-08 21:01
Muammar©13-Dec-08 21:01 
GeneralRe: Joining two columns together Pin
Mycroft Holmes14-Dec-08 14:03
professionalMycroft Holmes14-Dec-08 14:03 
GeneralRe: Joining two columns together Pin
Muammar©14-Dec-08 18:29
Muammar©14-Dec-08 18:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.