Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-Server
Hi to all,
just i want to know
"how to split string in sqlserver"
Posted 9-Aug-12 5:13am
panduu483
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...
 
A very quick search using your subject as the search term gave over 2 million hits: https://www.google.co.uk/search?q=how+to+split+string+in+sqlserver&sugexp=chrome,mod=10&sourceid=chrome&ie=UTF-8[^]
 
The second link gives a fully working SQL function: http://www.devaffair.com/2011/09/split-string-in-sql-server.html[^]
 
In future, please try to do at least basic research yourself, and not waste your time or ours.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Hi,
You can use SUBSTRING to split your strings in Sql Server.
Refer the links below:
MSDN : SUBSTRING (Transact-SQL)[^]
MSDN : SUBSTRING (Transact-SQL)-2[^]
MSDN : SUBSTRING[^]
 

--All the best.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

create table temp
(id varchar(50))
 
insert into temp values ('10/2000')
insert into temp values ('5/2000')
insert into temp values ('345/2000')
 
select SUBSTRING(id,1,charindex('/',id,0)-1) as id,
SUBSTRING(id,charindex('/',id,0)+1,LEN(id)-1) as year from temp
  Permalink  
Comments
Santhosh Kumar J at 9-Aug-12 10:16am
   
when you are copying someone answer, give them some credit...
_Amy at 9-Aug-12 10:19am
   
Finally caught. Ha ha.. ;)

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 169
1 Zoltán Zörgő 139
2 George Jonsson 135
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 9 Aug 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