Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I want to split a string 123test$%^ into different parts based on their type. Can any one help me.
Posted 13-Dec-12 23:34pm
Comments
OriginalGriff at 14-Dec-12 4:36am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Try SUBSTRING or RIGHT or LEFT; just check out the STRING functions for starters
 
DECLARE @frastr [nvarchar](128), @dmyndlstr[nvarchar](128), @nfrnchsint [int], @dracint [int]
SET @frastr = '123Test$%^'
SET @dmyndlstr = ''
SET @nfrnchsint = LEN(@frastr)
SET @dracint = 0
 
WHILE @dracint < @nfrnchsint + 1
    BEGIN
       SET @dmyndlstr = SUBSTRING(@frastr,0,@nfrnchsint + 1)
		PRINT @dmyndlstr
		SET @nfrnchsint = @nfrnchsint -1
	END
Or another SUBSTRING
DECLARE @frastr [nvarchar](128), @dmyndlstr[nvarchar](128), @nfrnchsint [int], @dracint [int]
SET @frastr = '123Test$%^'
SET @dmyndlstr = ''
SET @nfrnchsint = LEN(@frastr)
SET @dracint = 0
 
WHILE @dracint < @nfrnchsint + 2
    BEGIN
       SET @dmyndlstr = SUBSTRING(@frastr,0,LEN(@frastr)-@nfrnchsint)
		PRINT @dmyndlstr
		SET @nfrnchsint = @nfrnchsint -1
	END	
Or a LEFT and a RIGHT
DECLARE @frastr [nvarchar](128), @dmyndlstr[nvarchar](128), @nfrnchsint [int], @dracint [int]
SET @frastr = '123Test$%^'
SET @dmyndlstr = ''
SET @nfrnchsint = LEN(@frastr)
SET @dracint = 0
 
WHILE @dracint < @nfrnchsint
    BEGIN
       SET @dmyndlstr = LEFT(@frastr,1)
		PRINT @dmyndlstr
		SET @frastr = RIGHT(@frastr,@nfrnchsint-1)
		SET @nfrnchsint = @nfrnchsint -1
	END	
 
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 195
1 ProgramFOX 130
2 Maciej Los 105
3 Sergey Alexandrovich Kryukov 85
4 Afzaal Ahmad Zeeshan 82
0 OriginalGriff 6,564
1 Sergey Alexandrovich Kryukov 6,048
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100