Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Hi to all,
just i want to know
"how to split string in sqlserver"
Posted

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.
 
Share this answer
 
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.
 
Share this answer
 
SQL
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
 
Share this answer
 
Comments
Santhosh Kumar Jayaraman 9-Aug-12 10:16am    
when you are copying someone answer, give them some credit...
_Amy 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900